package cn.fl.ass.controller;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.framework.dto.SysDictionaryDTO;
import cmm.comm.facade.upload.condition.SysUlFilesRecQueryCondition;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.utils.*;
import cn.fl.ass.service.*;
import cn.fl.ass.transform.AssTrailCarDVOTransform;
import cn.fl.ass.vo.*;
import cn.fl.capital.service.ICapPayInfoService;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.framework.constant.DictionaryConstant;
import cn.fl.project.constant.PrjBscInfoConstant;
import cn.fl.project.constant.PrjPrdPaySchMConstant;
import cn.fl.project.dto.PrjPrdPaySchMDTO;
import cn.fl.project.service.IPrjBscInfoService;
import cn.fl.project.service.IPrjPaySchMYqService;
import cn.fl.project.service.IPrjPrdDtlService;
import cn.fl.project.service.IPrjPrdPaySchMApiService;
import cn.fl.project.vo.PrjBscInfoVO;
import cn.fl.project.vo.PrjPaySchMYqVO;
import cn.fl.sue.constant.SueDicCode;
import cn.fl.system.api.ISysSequenceApiService;
import cn.fl.system.condition.SysBkAccInfoQueryCondition;
import cn.fl.system.condition.SysBkInfoQueryCondition;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.service.ISysRegionService;
import cn.fl.system.service.ISysUlFilesRecService;
import cn.fl.system.service.ISysUsrService;
import cn.fl.system.vo.SysUlFilesRecVO;
import cn.fl.system.vo.SysUsrVO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import fl.ass.facade.condition.*;
import fl.ass.facade.constant.AssDealSellConstant;
import fl.ass.facade.constant.AssFileConstant;
import fl.ass.facade.constant.InterfaceConstants;
import fl.flow.facade.flow.condition.SysFlowSHQueryCondition;
import fl.flow.facade.flow.constant.FlowConstant;
import fl.flow.facade.flow.dto.SysFlowSHDTO;
import net.sf.json.JSONArray;
import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import veh.src.facade.src.src.api.IVehSrcInfQueryApiService;
import veh.src.facade.src.src.condition.VehSrcInfQC;
import veh.src.facade.src.src.dto.VehSrcInfDTO;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;

/**
 * @Description: 拖车信息主表 控制层
 */
@Controller
@RequestMapping("/ass/assTrailCarM")
public class AssTrailCarMController extends BaseController {

	private static final Logger logger = LoggerFactory.getLogger(AssTrailCarMController.class);

	/**
	 * AssTrailCarM 服务层BEAN
	 */
	@Autowired
	private IAssTrailCarMService assTrailCarMService;
	
	/**
	 * AssTrailCarD 服务层BEAN
	 */
	@Autowired
	private IAssTrailCarDService assTrailCarDService;
	
	/**
	 * AssDealCar 服务层BEAN
	 */
	@Autowired
	private IAssDealCarService assDealCarService;
	
	/**
	 * SysUlFilesRec 服务层BEAN
	 */
	@Autowired
	private ISysUlFilesRecService sysUlFilesRecService;
	
	/**
	 * AssTrailCarHv 服务层BEAN
	 */
	@Autowired
	private IAssTrailCarHvService assTrailCarHvService;
	
	/**
	 *AssDealRecAmtService 服务层BEAN
	 */
	@Autowired
	private IAssDealRecAmtService assDealRecAmtService;
	
	/**
	 *ISysUsrService 服务层BEAN
	 */
	@Autowired
	private ISysUsrService sysUsrService;
	
	/**
	 *IAssParkingValidService 服务层BEAN
	 */
	@Autowired
	private IAssParkingValidService assParkingValidService;
	
	/**
	 *IAssDealSellService 服务层BEAN
	 */
	@Autowired
	private IAssDealSellService assDealSellService;
	/**
	 *IAssDealRedeemService 服务层BEAN
	 */
	@Autowired
	private IAssDealRedeemService assDealRedeemService;
	
	/**
	 * 数据字典服务
	 */
	@Autowired
	private ISysDictionaryApiService sysDictionaryApiService;
	
	
	@Autowired
	private IAssTrailCarFlowInsMcrLngService assTrailCarFlowInsMcrLngService;
    /**
     * SysRegion 服务层BEAN
     */
    @Autowired
    private ISysRegionService sysRegionService;
    /**
     * AssTrailCarChannel 服务层BEAN
     */
    @Autowired
    private IAssTrailCarChannelService assTrailCarChannelService;
    
    @Autowired
    private IAssDealSellCostService assDealSellCostService;

    /**
     * 车型库的服务
     */
    @Autowired
    private IVehSrcInfQueryApiService vehSrcInfQueryApiService;

    /**
     * 项目基础信息服务
     */
    @Autowired
    private IPrjBscInfoService prjBscInfoService;

    /**
     * 支付表主表服务
     */
    @Autowired
    private IPrjPrdPaySchMApiService prjPrdPaySchMApiService;

    @Autowired
    private ISysSequenceApiService sysSequenceApiService;

	/**
	 * 到拖车管理列表页面
	 */
	@RequestMapping(value = "/toListPage.do", method = { RequestMethod.GET})
	public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("ass/assTrailCarM/assTrailCarManager");
		String grpCd = InterfaceConstants.DEAL_STS_CD;//处置状态
		String sysCd = CurrentThreadContext.getCurrentSysCd(); 
		String orgCd = CurrentThreadContext.getCurrentOrgCd();
		//获取处置状态
		List<KeyValueVO> dealStsList = this.assTrailCarMService.getKvList(grpCd, sysCd, orgCd);
		view.addObject("dealStsList", dealStsList);
		//获取拖车状态
		grpCd = InterfaceConstants.BACK_STATUS_CD;//拖车状态
		List<KeyValueVO> backStsList = this.assTrailCarMService.getKvList(grpCd, sysCd, orgCd);
		view.addObject("backStsList", backStsList);
		return view;
	}

	/**
	 * 到修改页面
	 */
	@RequestMapping(value = "/toModifyPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		ModelAndView view = new ModelAndView("ass/assTrailCarM/modify");
		view.addObject("id", id);
		return view;
	}
	
	/**
	 * 到拖车申请流程附加信息页面
	 */
	@RequestMapping(value = "/toViewPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toViewPage(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		//获取流程传过来的参数：拖车主表ID
		String tcMasterId = request.getParameter("tcMasterId");
		String proIntId = request.getParameter("processInstanceId");//流程实例ID
		String sysCd = CurrentThreadContext.getCurrentSysCd(); 
		String orgCd = CurrentThreadContext.getCurrentOrgCd();
		String flag = request.getParameter("flag");
		// 是否是新流程的表单
		String isNew = request.getParameter("isNew");
		ModelAndView view = new ModelAndView("ass/assTrailCarD/assTrailCarDView");
        String isNeedValid = assTrailCarMService.isNeedValid(Long.valueOf(tcMasterId));
        if (BaseConstant.IS_YESNO_YES_STR.equals(isNeedValid)) {
            view.addObject("isNeedValid", isNeedValid);
        }
		//处置接收人类型
		List<KeyValueVO> backFlagList = this.assTrailCarMService.getKvList(InterfaceConstants.BACK_FLAG_CD, sysCd, orgCd);
        //2018 09 13 add by zk 修改拖车渠道
        //获取下拉渠道备案省
        List<KeyValueVO> provinceKVList = this.sysRegionService.searchProvinceKVList();
        KeyValueVO keyValueVO = new KeyValueVO();
        keyValueVO.setKey("ALL");
        keyValueVO.setValue("总部");
        provinceKVList.add(0, keyValueVO);
        //获取渠道名称
        Long channelId = null;
        String channelNm = null;
        String recordPrCd = null;
        AssTrailCarMVO assTrailCarMVO = assTrailCarMService.selectById(Long.valueOf(tcMasterId));
        if (null != assTrailCarMVO) {
            channelId = assTrailCarMVO.getChannelId();
            if (StringUtils.isNotEmpty(channelId)) {
                AssTrailCarChannelVO assTrailCarChannelVO = assTrailCarChannelService.selectById(channelId);
                if (null != assTrailCarChannelVO) {
                    channelNm = assTrailCarChannelVO.getChannelNm();
                    recordPrCd = assTrailCarChannelVO.getRecordPrCd();
                }
            }
        }
        // 根据拖车明细查发起拖车的支付表（启用）在找到我司支付表
        if (StringUtils.isNotEmpty(tcMasterId)) {
            AssTrailCarDQueryCondition qc = new AssTrailCarDQueryCondition();
            qc.setMasterId(Long.valueOf(tcMasterId));
            qc.setIsDel(BaseConstant.IS_YESNO_NO);
            qc.setIsHis(BaseConstant.IS_YESNO_NO);
            List<AssTrailCarDVO> voList = this.assTrailCarDService.searchDetailList(qc);
            if (CollectionUtils.isNotEmpty(voList)) {
                Long paySchId = voList.get(0).getPaySchId();
                List<PrjPrdPaySchMDTO> prjPrdPaySchMDTOS = this.prjPrdPaySchMApiService.searchTheSamePrdOtherPaySchMList(paySchId);
                for (PrjPrdPaySchMDTO prjPrdPaySchMDTO : prjPrdPaySchMDTOS) {
                    if (PrjPrdPaySchMConstant.PAY_SCH_TYP_CD_WS.equals(prjPrdPaySchMDTO.getPaySchTypCd())) {
                        view.addObject("wsPaySchId", prjPrdPaySchMDTO.getId());
                        view.addObject("wsPaySchNo", prjPrdPaySchMDTO.getPaySchNo());
                    }
                }
            }
        }
        view.addObject("provinceKVList", provinceKVList);
		view.addObject("backFlagList", backFlagList);
		view.addObject("tcMasterId", tcMasterId);
		view.addObject("proIntId", proIntId);		
		view.addObject("flag", flag);
        view.addObject("isNew", isNew);
		view.addObject("sysDate", DateUtils.formatDateToString(new Date(), DateUtils.YYYY_MM_DD));
		view.addObject("loginUsrNm", CurrentThreadContext.getCurrentUserName());

        view.addObject("channelId", channelId);
        view.addObject("channelNm", channelNm);
        view.addObject("recordPrCd", recordPrCd);

        String mdfMarket = request.getParameter("mdfMarket");//市场评估价,市场评估时间修改标识
        if(StringUtils.isEmpty(mdfMarket) && "19".equals(flag)){//优车系统管理员核查入库
        	mdfMarket = "1";
        }
        view.addObject("mdfMarket", mdfMarket);
        List<KeyValueVO> expressNm = this.sysDictionaryApiService.getKvList(InterfaceConstants.EXPRESS_NM, InterfaceConstants.SYS_CODE, InterfaceConstants.ORG_CODE);
        List<KeyValueVO> rcvRelationship = this.sysDictionaryApiService.getKvList(InterfaceConstants.RCV_RELATIONSHIP, InterfaceConstants.SYS_CODE, InterfaceConstants.ORG_CODE);
        List<KeyValueVO> backWayCd = this.sysDictionaryApiService.getKvList(InterfaceConstants.BACK_WAY_CD, InterfaceConstants.SYS_CODE, InterfaceConstants.ORG_CODE);
        view.addObject("expressNm", expressNm);
        view.addObject("rcvRelationship", rcvRelationship);
        view.addObject("backWayCd", backWayCd);
        return view;
	}
	
	/**
	 * 到拖车单信息页面
	 */
	@RequestMapping(value = "/toInfoViewPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toInfoViewPage(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		//获取拖车主表ID
		String tcMasterId = request.getParameter("tcMasterId");
		String tcDetailId = request.getParameter("tcDetailId");
		String crflag = request.getParameter("crflag");//出入库标识
		String busid = request.getParameter("busid");
		String processId= request.getParameter("processId");
		String taskDefKey= request.getParameter("taskDefKey");

		ModelAndView view = new ModelAndView("ass/assTrailCarD/assTrailCarInfoView");
		// 根据拖车明细里的支付表（启用）查我司支付表
		if (StringUtils.isNotEmpty(tcDetailId)) {
            AssTrailCarDVO assTrailCarDVO = this.assTrailCarDService.selectById(Long.valueOf(tcDetailId));
            if (StringUtils.isNotEmpty(assTrailCarDVO.getPaySchId())) {
                List<PrjPrdPaySchMDTO> prjPrdPaySchMDTOS = this.prjPrdPaySchMApiService.searchTheSamePrdOtherPaySchMList(Long.valueOf(assTrailCarDVO.getPaySchId()));
                if (CollectionUtils.isNotEmpty(prjPrdPaySchMDTOS)) {
                    for (PrjPrdPaySchMDTO prjPrdPaySchMDTO : prjPrdPaySchMDTOS) {
                        if (PrjPrdPaySchMConstant.PAY_SCH_TYP_CD_WS.equals(prjPrdPaySchMDTO.getPaySchTypCd())) {
                            view.addObject("wsPaySchId", prjPrdPaySchMDTO.getId());
                            view.addObject("wsPaySchNo", prjPrdPaySchMDTO.getPaySchNo());
                        }
                    }
                }
            }
        }
        if (StringUtils.isNotEmpty(tcMasterId)) {
            AssTrailCarDQueryCondition qc = new AssTrailCarDQueryCondition();
            qc.setMasterId(Long.valueOf(tcMasterId));
            List<AssTrailCarDVO> assTrailCarDVOS = this.assTrailCarDService.searchDetailList(qc);
            if (CollectionUtils.isEmpty(assTrailCarDVOS)) {
                throw new BaseException("未查询到拖车明细数据，MasterId = " + tcMasterId);
            }
            if (StringUtils.isNotEmpty(assTrailCarDVOS.get(0).getPaySchId())) {
                List<PrjPrdPaySchMDTO> prjPrdPaySchMDTOS = this.prjPrdPaySchMApiService.searchTheSamePrdOtherPaySchMList(Long.valueOf(assTrailCarDVOS.get(0).getPaySchId()));
                if (CollectionUtils.isNotEmpty(prjPrdPaySchMDTOS)) {
                    for (PrjPrdPaySchMDTO prjPrdPaySchMDTO : prjPrdPaySchMDTOS) {
                        if (PrjPrdPaySchMConstant.PAY_SCH_TYP_CD_WS.equals(prjPrdPaySchMDTO.getPaySchTypCd())) {
                            view.addObject("wsPaySchId", prjPrdPaySchMDTO.getId());
                            view.addObject("wsPaySchNo", prjPrdPaySchMDTO.getPaySchNo());
                        }
                    }
                }
            }
        }
		view.addObject("tcMasterId", tcMasterId);
		view.addObject("tcDetailId", tcDetailId);
		view.addObject("crflag", crflag);
		view.addObject("busid", busid);
		view.addObject("processId", processId);
		view.addObject("taskDefKey", taskDefKey);
		
		String mdfSellCost= request.getParameter("mdfSellCost");//是否可以编辑处置变卖费用信息
		view.addObject("mdfSellCost", mdfSellCost);
		
		//查询拖车明细费用类型大类
		List<KeyValueVO> costMainCdList = this.assDealSellCostService.searchCostCdListByLvl("1");
		view.addObject("costMainCdListJSON", JSONObject.toJSON(costMainCdList));
		
		view.addObject("currentUserName", CurrentThreadContext.getCurrentUserName());
		view.addObject("currentDate", DateUtils.getCurrentDateStr(DateUtils.YYYY_MM_DD));
		return view;
	}
	
	/**
	 * 获取费用类型下拉数据
	 */
	@RequestMapping(value = "/getCostCdJSON.do", method = { RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public Object getCostCdJSON(HttpServletRequest request, HttpServletResponse response){
		String lvl = request.getParameter("lvl");
		String PCode = request.getParameter("PCode");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(lvl) && StringUtils.isEmpty(PCode)){
			return result;
		}
		List<KeyValueVO> goodsTypList = new ArrayList<KeyValueVO>();
		try{
			if(StringUtils.isNotEmpty(lvl)){
				goodsTypList = this.assDealSellCostService.searchCostCdListByLvl(lvl);
			}else if(StringUtils.isNotEmpty(PCode)){
				goodsTypList = this.assDealSellCostService.searchCostCdListByPCode(PCode);
			}
			if(CollectionUtils.isNotEmpty(goodsTypList)){
				result.setData(JSONObject.toJSON(goodsTypList));
			}
		}catch(BaseException ex) {
			BaseLogUtils.newLogger("获取费用类型失败").setThrowable(ex).setKeys("lvl:" + lvl, "PCode:" + PCode).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
			throw ex;
		}catch(Exception ex) {
            BaseLogUtils.newLogger("获取费用类型失败").setThrowable(ex).setKeys("lvl:" + lvl, "PCode:" + PCode).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
		}
		
		return result;
	}
	
	/**
	 * 到拖车管理-流程跟踪页面
	 */
	@RequestMapping(value = "/toFlowPage.do", method = { RequestMethod.GET})
	public ModelAndView toFlowPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("ass/assTrailCarM/assFlowInfoList");
		String tcMasterId = request.getParameter("tcMasterId");
		String tcDetailId = request.getParameter("tcDetailId");
		//设置拖车主表ID和明细表ID值
		view.addObject("tcMasterId", tcMasterId);
		view.addObject("tcDetailId", tcDetailId);
		return view;
	}
	
	/**
	 * 到拖车处置选择页面
	 */
	@RequestMapping(value = "/toDealSelectPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toDealSelectPage(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		ModelAndView view = new ModelAndView("ass/assTrailCarM/assDealSelectPage");
		return view;
	}
	
	/**
	 * 到拖车管理-处置申请页面
	 */
	@RequestMapping(value = "/toDealApplyPage.do", method = { RequestMethod.GET})
	public ModelAndView toDealApplyPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("ass/assTrailCarM/assDealApplyPage");
		String tcMasterId = request.getParameter("tcMasterId");
		String tcDetailId = request.getParameter("tcDetailId");
		String infoId = request.getParameter("infoId");
		String prjPrdDtlId = request.getParameter("prjPrdDtlId");
		String cstId = request.getParameter("cstId");
		String cstNm = request.getParameter("cstNm");
		String orgName = request.getParameter("orgName");
		String buOrgCd = request.getParameter("buOrgCd");
		String backedFlagCd = request.getParameter("backedFlagCd");
		String baseAmt = request.getParameter("baseAmt");
		String prjId = request.getParameter("prjId");
		String businessType = request.getParameter("businessType");
		String prjTypCd = request.getParameter("prjTypCd");
		String prjNm = request.getParameter("prjNm");
		String sysCd = CurrentThreadContext.getCurrentSysCd(); 
		String orgCd = CurrentThreadContext.getCurrentOrgCd();
        if (StringUtils.isNotEmpty(prjId)) {
            boolean check = this.assTrailCarDService.checkCarIsChanging(Long.valueOf(prjId), Long.valueOf(prjPrdDtlId));
            if (check) {
                throw new BaseException("车辆换车中，不允许发起该流程");
            }
            PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(Long.valueOf(prjId));
            if (null != prjBscInfoVO) {
                // 判断是否资管业务
                Integer isInsBiz = prjBscInfoVO.getIsInsBiz();
                if (BaseConstant.IS_YESNO_YES == isInsBiz) {
                    throw new BaseException("资管业务暂不支持发起拖车处置");
                }
            }
        }
        boolean check = this.assTrailCarMService.checkDealOrTransUsedFlowStart(Long.valueOf(tcMasterId));
        if (false == check) {
            throw new BaseException("绑定未申请放款的车抵贷业务YQ项目，请先作废或放款");
        }
		AssDealSellQueryCondition  condition = new AssDealSellQueryCondition();
		condition.setMasterId(Long.valueOf(tcMasterId));
		List<AssDealSellVO> assDealSellList = this.assDealSellService.searchAssDealSellList(condition);
		if(CollectionUtils.isNotEmpty(assDealSellList) && assDealSellList.size()>=0) {
            AssDealSellVO assDealSellVO = assDealSellList.get(0);
            Long sellEstiAmt = assDealSellVO.getSellEstiAmt();
            Date sellEstiDt = assDealSellVO.getSellEstiDt();
            Long sellAmt = assDealSellVO.getSellAmt();
            view.addObject("sellEstiAmt", sellEstiAmt);//处置评估价
            view.addObject("sellAmt", sellAmt);//处置金额
            view.addObject("sellEstiDt", DateUtils.formatDateToString(sellEstiDt, DateUtils.YYYY_MM_DD));
        }
        AssDealSellVO assDealSellVO = new AssDealSellVO();
        Long id = assDealSellService.add(assDealSellVO);
        view.addObject("sellId", id);
		//亏损原因
        List<KeyValueVO> lossCauseCdJosn = this.assTrailCarMService.getKvList(InterfaceConstants.LOSS_CAUSE_CD, sysCd, orgCd);
		//处置接收人类型
		List<KeyValueVO> buyerTypeList = this.assTrailCarMService.getKvList(InterfaceConstants.BUYER_TYPE_CD, sysCd, orgCd);
		view.addObject("buyerTypeList", buyerTypeList);
		//处置路径
		List<KeyValueVO> sellChannelList = this.assTrailCarMService.getKvList(InterfaceConstants.SELL_CHANNEL_CD, sysCd, orgCd);
		view.addObject("sellChannelList", sellChannelList);
		//数据类型
		List<KeyValueVO> dataTypeList = this.assTrailCarMService.getKvList(InterfaceConstants.DATA_TYPE_CD_SY, sysCd, orgCd);
		//获取保底价格及经营贷——LNG——保险贷
		Long money=assTrailCarFlowInsMcrLngService.getAllMoney(tcMasterId);
		view.addObject("dataTypeList", dataTypeList);
		//设置拖车主表ID和明细表ID值
		view.addObject("tcMasterId", tcMasterId);
		view.addObject("tcDetailId", tcDetailId);
		view.addObject("infoId", infoId);
		view.addObject("prjPrdDtlId", prjPrdDtlId);//项目产品明细表ID
		view.addObject("cstId", cstId);
		view.addObject("cstNm", cstNm);
		view.addObject("orgName", orgName);
		view.addObject("buOrgCd", buOrgCd);
		view.addObject("backedFlagCd", backedFlagCd);
		view.addObject("baseAmt", baseAmt);//保底价	
		view.addObject("baseAllAmt", money);
		view.addObject("prjId", prjId);//项目基础信息表ID
		view.addObject("businessType", businessType);
		view.addObject("prjTypCd", prjTypCd);
		view.addObject("prjNm", prjNm);//项目名称
		view.addObject("sysDate", DateUtils.formatDateToString(new Date(), DateUtils.YYYY_MM_DD));
		view.addObject("applyNm", CurrentThreadContext.getCurrentUserName());
		view.addObject("sysDate", DateUtils.formatDateToString(new Date(), DateUtils.YYYY_MM_DD));
		view.addObject("loginUsrNm", CurrentThreadContext.getCurrentUserName());
		view.addObject("lossCauseCdJosn", JSON.toJSON(lossCauseCdJosn));//亏损原因
		return view;
	}
	
	/**
	 * 到拖车管理-赎回申请页面
	 */
	@RequestMapping(value = "/toRedeemApplyPage.do", method = { RequestMethod.GET})
	public ModelAndView toRedeemApplyPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("ass/assTrailCarM/assRedeemApplyPage");
		String tcMasterId = request.getParameter("tcMasterId");
		String tcDetailId = request.getParameter("tcDetailId");
		String paySchId = request.getParameter("paySchId");
		String prjPrdDtlId = request.getParameter("prjPrdDtlId");
		String cstId = request.getParameter("cstId");
		String cstNm = request.getParameter("cstNm");
		String buOrgCd = request.getParameter("buOrgCd");
		String backedFlagCd = request.getParameter("backedFlagCd");
		String actPayAmt = request.getParameter("actPayAmt");
		String prjId = request.getParameter("prjId");
		String businessType = request.getParameter("businessType");
		String prjTypCd = request.getParameter("prjTypCd");
		String prjNm = request.getParameter("prjNm");
		String orgName = request.getParameter("orgName");
		String sysCd = CurrentThreadContext.getCurrentSysCd(); 
		String orgCd = CurrentThreadContext.getCurrentOrgCd();
		try {
            if (StringUtils.isNotEmpty(prjId)) {
                boolean check = this.assTrailCarDService.checkCarIsChanging(Long.valueOf(prjId), Long.valueOf(prjPrdDtlId));
                if (check) {
                    throw new BaseException("车辆换车中，不允许发起该流程");
                }
                PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(Long.valueOf(prjId));
                if (null != prjBscInfoVO) {
                    // 判断是否资管业务
                    Integer isInsBiz = prjBscInfoVO.getIsInsBiz();
                    if (BaseConstant.IS_YESNO_YES == isInsBiz) {
                        throw new BaseException("资管业务暂不支持发起拖车赎回");
                    } else if (BaseConstant.IS_YESNO_NO == isInsBiz) {
                        // 非资管业务
                        List<PrjPrdPaySchMDTO> paySchMDTOS = this.prjPrdPaySchMApiService.selectEnabledListByPaySchId(Long.valueOf(paySchId));
                        if (CollectionUtils.isNotEmpty(paySchMDTOS)) {
                            PrjPrdPaySchMDTO dto = paySchMDTOS.get(0);
                            String enabledPaySchId = String.valueOf(dto.getId());
                            String enabledPaySchNo = dto.getPaySchNo();
                            view.addObject("enabledPaySchId", enabledPaySchId);
                            view.addObject("enabledPaySchNo", enabledPaySchNo);
                        }
                    }
                }
            }
            Long redeemId = sysSequenceApiService.getFun("FN_GEN_ASS_DEAL_REDEEM_ID");
            //赎回方式
            List<KeyValueVO> redeemTypeList = this.assTrailCarMService.getKvList(InterfaceConstants.REDEEM_TYPE_CD, sysCd, orgCd);
            view.addObject("redeemTypeList", redeemTypeList);
            //赎回保证金计算基数类型
            List<SysDictionaryDTO> amtTypeCdList = sysDictionaryApiService.searchGroup(sysCd, orgCd, InterfaceConstants.AMT_TYPE_CD);
            //获取保底价格及经营贷——LNG——保险贷
            Long money = assTrailCarFlowInsMcrLngService.getAllMoney(tcMasterId);
            //赎回方式
            List<KeyValueVO> redeemWayList = this.assTrailCarMService.getKvList(InterfaceConstants.REDEEM_WAY_CD, sysCd, orgCd);
            view.addObject("redeemWayList", redeemWayList);
            view.addObject("amtTypeCdList", amtTypeCdList);
            //设置拖车主表ID和明细表ID值
            view.addObject("tcMasterId", tcMasterId);
            view.addObject("tcDetailId", tcDetailId);
            view.addObject("redeemId", redeemId);
            view.addObject("paySchId", paySchId);
            view.addObject("prjPrdDtlId", prjPrdDtlId);//项目产品明细表ID
            view.addObject("cstId", cstId);
            view.addObject("cstNm", cstNm);
            view.addObject("buOrgCd", buOrgCd);
            view.addObject("backedFlagCd", backedFlagCd);
            view.addObject("actPayAmt", actPayAmt);
            view.addObject("prjId", prjId);//项目基础信息表ID
            view.addObject("businessType", businessType);
            view.addObject("prjTypCd", prjTypCd);
            view.addObject("prjNm", prjNm);//项目名称
            view.addObject("orgName", orgName);//项目所属事业部名称
            view.addObject("baseAllAmt", money);
            view.addObject("sysDate", DateUtils.formatDateToString(new Date(), DateUtils.YYYY_MM_DD));
            view.addObject("applyNm", CurrentThreadContext.getCurrentUserName());
            return view;
        } catch (BaseException e) {
		    BaseLogUtils.newLogger("发起拖车赎回失败").setKeys("tcMasterId:" + tcMasterId).setThrowable(e).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
		    throw e;
        } catch (Exception e) {
            BaseLogUtils.newLogger("发起拖车赎回失败").setKeys("tcMasterId:" + tcMasterId).setThrowable(e).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw e;
        }
	}

	/**
	 * 初始化拖车管理列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}

		AssTrailCarDQueryCondition qc = this.initTrailParam(request, response);
		qc.setUsrId(CurrentThreadContext.getCurrentUserId());
		qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
		page.setCondition(qc);
		
		Pager pager = this.assTrailCarMService.searchListPage(page);
		List<AssTrailCarDVO> list = (List<AssTrailCarDVO>) pager.getResultList();
		ListPageVO<AssTrailCarDVO> listPage = new ListPageVO<AssTrailCarDVO>(list, pager.getTotalCount());
		return listPage;
	}
	
	/**
	 * 初始化拖车管理列表-获取查询参数
	 */
	public AssTrailCarDQueryCondition initTrailParam(HttpServletRequest request, HttpServletResponse response) {
		//获取页面参数-共同参数
		String cstNm = request.getParameter("cstNm");
		String contNo = request.getParameter("contNo");
		String paySchNo = request.getParameter("paySchNo");
		//拖车管理-查询特有参数
		String minBackDay = request.getParameter("minBackDay");
		String maxBackDay = request.getParameter("maxBackDay");
		String beginBackDate = request.getParameter("beginBackDate");
		String endBackDate = request.getParameter("endBackDate");
		String dealStsCd = request.getParameter("dealStsCd");
		//拖车申请--查询特有参数
		String minDay = request.getParameter("minOverdueDay");
		String maxDay = request.getParameter("maxOverdueDay");
		String backStsCd = request.getParameter("backStsCd");
		//选中行的支付表idList集合
		String pkIds = request.getParameter("pkIds");
		
		AssTrailCarDQueryCondition qc = new AssTrailCarDQueryCondition();
		if (StringUtils.isNotEmpty(cstNm)) {//客户名称
			qc.setCstNm(cstNm);
		}
		if (StringUtils.isNotEmpty(contNo)) {//合同号
			qc.setContNo(contNo);
		}
		if (StringUtils.isNotEmpty(paySchNo)) {//支付表号
			qc.setPaySchNo(paySchNo);
		}
		if (StringUtils.isNotEmpty(minBackDay)) {//拖回天数-最小值
			qc.setMinBackDay(Integer.parseInt(minBackDay));
		}
		if (StringUtils.isNotEmpty(maxBackDay)) {//拖回天数-最大值
			qc.setMaxBackDay(Integer.parseInt(maxBackDay));
		}
		if (StringUtils.isNotEmpty(beginBackDate)) {//拖回日期-开始
			qc.setBeginBackDate(DateUtils.formatStringToDate(beginBackDate, DateUtils.YYYY_MM_DD));
		}
		if (StringUtils.isNotEmpty(endBackDate)) {//拖回日期-结束
			qc.setEndBackDate(DateUtils.formatStringToDate(endBackDate, DateUtils.YYYY_MM_DD));
		}
		if (StringUtils.isNotEmpty(dealStsCd)) {//处置状态
			qc.setDealStsCd(dealStsCd);
		}
		if (StringUtils.isNotEmpty(minDay)) {//逾期天数-最小值
			Long minOverdueDay = Long.parseLong(minDay);
			qc.setMinOverdueDay(minOverdueDay);
		}
		if (StringUtils.isNotEmpty(maxDay)) {//逾期天数-最大值
			Long maxOverdueDay = Long.parseLong(maxDay);
			qc.setMaxOverdueDay(maxOverdueDay);
		}
		if (StringUtils.isNotEmpty(backStsCd)) {//拖车状态
			qc.setBackStsCd(backStsCd);
		}
		//要导出的拖车信息关联的支付表idList集合
		if(StringUtils.isNotEmpty(pkIds)){
			List<String> pkIdsList = new ArrayList<String>();
			JSONArray pkIdsArray = JSONArray.fromObject(pkIds);
			for (Object object : pkIdsArray) {
				pkIdsList.add(object.toString());
			}
			qc.setPkIdsList(pkIdsList);
		}
		qc.setUsrId(CurrentThreadContext.getCurrentUserId());
		qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
		return qc;
	}

	/**
	 * 删除数据
	 */
	@RequestMapping(value = "/removeById.do", method = {RequestMethod.POST })
	@ResponseBody
	public DataResultVO removeById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}
		try {
			this.assTrailCarMService.removeById(Long.valueOf(id));
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
		}

		return result;
	}

	/**
	 * 得到一条记录
	 * 获取转优车主表详情
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getOptimalInfoById.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getOptimalInfoById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}
		
		try {
			AssTrailCarMVO vo = this.assTrailCarMService.selectById(Long.valueOf(id));
			if(null == vo){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
			}
			result.setData(vo);
		}catch(BaseException ex) {
			BaseLogUtils.newLogger("获取转优车主表详情失败").setThrowable(ex).setKeys("id:" + id).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
			throw ex;
		}catch(Exception ex) {
            BaseLogUtils.newLogger("获取转优车主表详情失败").setThrowable(ex).setKeys("id:" + id).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
		}
		return result;
	}

	/**
	 * 新增拖车信息主表数据
	 * 同时发起拖车申请流程
	 */
	@RequestMapping(value = "/add.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object add(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		//获取页面参数
		String paySchId = request.getParameter("paySchId");
		// 启用支付表
		String enabledPaySchId = request.getParameter("enabledPaySchId");
		// 如果启用支付表不为空，则代表是非资管业务发起拖车
		if (StringUtils.isNotEmpty(enabledPaySchId)) {
            paySchId = enabledPaySchId;
        }
		String isOnline = request.getParameter("isOnline");
		String parkId = request.getParameter("parkId");
		String manageId = request.getParameter("manageId");
		String provinceCd = request.getParameter("provinceCd");
		String cityCd = request.getParameter("cityCd");
		String backReason = request.getParameter("backReason");
		String backDt = request.getParameter("backDt");
		String companyNm = request.getParameter("companyNm");
		String backPrice = request.getParameter("backPrice");
		String backQty = request.getParameter("backQty");
		String backAmt = request.getParameter("backAmt");
		String payeeAccNm = request.getParameter("payeeAccNm");
		String payeeAccNo = request.getParameter("payeeAccNo");
		String payeeBankNm = request.getParameter("payeeBankNm");
		String payeeBankNo = request.getParameter("payeeBankNo");
		String applyNm = request.getParameter("applyNm");
		String applyDt = request.getParameter("applyDt");
		String prjPrdDtlId = request.getParameter("prjPrdDtlId");
		String prjId = request.getParameter("prjId");
		String businessType = request.getParameter("businessType");
		String prjTypCd = request.getParameter("prjTypCd");
		String prjNm = request.getParameter("prjNm");
		String orgName = request.getParameter("orgName");
		String cstId = request.getParameter("cstId");
		String cstNm = request.getParameter("cstNm");

        String channelId = request.getParameter("channelId");//渠道ID

		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
        if (StringUtils.isNotEmpty(prjId)) {
            PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(Long.valueOf(prjId));
            if (null != prjBscInfoVO && prjBscInfoVO.getPrjTypCd().equals(PrjBscInfoConstant.PRJ_TYP_CD_CDDYWYQ)) {
                return new DataResultVO(BaseConstant.IS_YESNO_NO, "车抵贷业务（YQ）不可申请拖车");
            }
        }
		AssTrailCarMVO entity = new AssTrailCarMVO();
		List<Long> ids = new ArrayList<Long>();
		Map<String,Object> map = new HashMap<String,Object>();
		//判断支付表ID是否为空
		if(StringUtils.isEmpty(paySchId)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}else{
			ids.add(Long.valueOf(paySchId));
		}
		try {
			//设置主表实体属性
			if(StringUtils.isNotEmpty(parkId)){
				entity.setParkId(Long.parseLong(parkId));
			}
			if(StringUtils.isNotEmpty(manageId)){
				entity.setManageId(Long.parseLong(manageId));
			}
			if(StringUtils.isNotEmpty(backDt)){
				entity.setBackDt(DateUtils.formatStringToDate(backDt, DateUtils.YYYY_MM_DD));
			}
			if(StringUtils.isNotEmpty(backPrice)){//元转分
				entity.setBackPrice(DecimalUtils.convertYuanToFen(Double.valueOf(backPrice)));
			}
			if(StringUtils.isNotEmpty(backQty)){
				entity.setBackQty(Integer.parseInt(backQty));
			}
			if(StringUtils.isNotEmpty(backAmt)){//元转分
				entity.setBackAmt(DecimalUtils.convertYuanToFen(Double.valueOf(backAmt)));
			}
			if(StringUtils.isNotEmpty(applyDt)){
				entity.setApplyDt(DateUtils.formatStringToDate(applyDt, DateUtils.YYYY_MM_DD));
			}
            if(StringUtils.isNotEmpty(channelId)){
                entity.setChannelId(Long.valueOf(channelId));
            }
			entity.setProvinceCd(provinceCd);
			entity.setCityCd(cityCd);
			entity.setBackReason(backReason);
			entity.setCompanyNm(companyNm);
			entity.setPayeeAccNm(payeeAccNm);
			entity.setPayeeAccNo(payeeAccNo);
			entity.setPayeeBankNm(payeeBankNm);
			entity.setPayeeBankNo(payeeBankNo);
			entity.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
			entity.setCrtTm(new Date());
			entity.setIsDel(BaseConstant.IS_YESNO_NO);
			entity.setApplyNm(applyNm);
			entity.setApplyId(CurrentThreadContext.getCurrentUserId());
			//根据支付表ID获取拖车基本信息
			List<AssTrailCarDVO> details = this.assTrailCarDService.selectByPaySchId(ids);
			String orgSimpleCode = "";
			if(null == details){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				return result;
			}else{
				if(details.size() > 0 && null != details.get(0)){
				    BaseLogUtils.newLogger("拖车申请支付表号").setKeys("paySchNo:" + details.get(0).getPaySchNo()).info();
					map.put("orgCode",details.get(0).getOrgSimpleCode());//事业部简称
					orgSimpleCode = details.get(0).getOrgSimpleCode();
					if(StringUtils.isNotEmpty(isOnline)){//GPS在线状态
						details.get(0).setIsOnline(Integer.parseInt(isOnline));
					}
				}
				//设置详细实体信息
				entity.setDetails(AssTrailCarDVOTransform.toDTOList(details));
			}
			getExtRequestParams(request, entity);
			// 保存拖车信息
			Long id = this.assTrailCarMService.add(entity);
			if (StringUtils.isEmpty(id)) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("保存拖车信息异常");
                return result;
            }
			//设置流程参数
			AssTrailCarDQueryCondition qc = new AssTrailCarDQueryCondition();
			qc.setId(id);//拖车主表ID
			qc.setOrgName(orgName);//项目所属事业部名称
			qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
			qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
			qc.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());//当前登录人事业部代码
			qc.setUsrId(CurrentThreadContext.getCurrentUserId());
			qc.setUsrNm(CurrentThreadContext.getCurrentUserName());
			if("ZC".equals(map.get("orgCode"))){
				qc.setFlowModelType(FlowConstant.FLOW_MODEL_TYP_ASS_APPROVAL);//"017"专车拖车审批也走拖车审批流程
        	}else {
				qc.setFlowModelType(FlowConstant.FLOW_MODEL_TYP_ASS_APPROVAL);//"017"拖车审批
			}			
			qc.setFlow_Map(map);//附加参数
			if(StringUtils.isNotEmpty(prjPrdDtlId)){//项目产品明细表ID
				qc.setPrjPrdDtlId(Long.parseLong(prjPrdDtlId));
			}
			if(StringUtils.isNotEmpty(prjId)){//项目基础信息表ID
				qc.setPrjId(Long.parseLong(prjId));
			}
			if(StringUtils.isNotEmpty(cstId)){//客户ID
				qc.setCstId(Long.parseLong(cstId));
			}
			qc.setBusinessType(businessType);
			qc.setPrjTypCd(prjTypCd);
			qc.setPrjNm(prjNm);
			qc.setCstNm(cstNm);
			//发起拖车申请流程
			result = this.assTrailCarMService.addTrailCarApply(qc);
			
			result.setData(id);
		}catch (BaseException ex) {
			BaseLogUtils.newLogger("新增拖车信息主表数据并发起拖车流程失败").setThrowable(ex).setKeys("DATA:" + JSONObject.toJSONString(entity)).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
			throw ex;
		}catch (Exception ex) {
            BaseLogUtils.newLogger("新增拖车信息主表数据并发起拖车流程失败").setThrowable(ex).setKeys("DATA:" + JSONObject.toJSONString(entity)).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
		}

		return result;
	}

	private void getExtRequestParams(HttpServletRequest request, AssTrailCarMVO entity) {
        String isSendFile = request.getParameter("isSendFile");
        String notSendReason = request.getParameter("notSendReason");
        String expressNm = request.getParameter("expressNm");
        String expressNum = request.getParameter("expressNum");
        String rcvRelationship = request.getParameter("rcvRelationship");
        String rcvNm = request.getParameter("rcvNm");
        String rcvTel = request.getParameter("rcvTel");
        String rcvAddr = request.getParameter("rcvAddr");
        String backWayCd = request.getParameter("backWayCd");
        if (StringUtils.isNotEmpty(isSendFile)) {
            entity.setIsSendFile(isSendFile);
        }
        if (StringUtils.isNotEmpty(notSendReason)) {
            entity.setNotSendReason(notSendReason);
        }
        if (StringUtils.isNotEmpty(expressNm)) {
            entity.setExpressNm(expressNm);
        }
        if (StringUtils.isNotEmpty(expressNum)) {
            entity.setExpressNum(expressNum);
        }
        if (StringUtils.isNotEmpty(rcvRelationship)) {
            entity.setRcvRelationship(rcvRelationship);
        }
        if (StringUtils.isNotEmpty(rcvNm)) {
            entity.setRcvNm(rcvNm);
        }
        if (StringUtils.isNotEmpty(rcvTel)) {
            entity.setRcvTel(rcvTel);
        }
        if (StringUtils.isNotEmpty(rcvAddr)) {
            entity.setRcvAddr(rcvAddr);
        }
        if (StringUtils.isNotEmpty(backWayCd)) {
            entity.setBackWayCd(backWayCd);
        }
    }

	/**
	 * 修改拖车主表信息
	 */
	@RequestMapping(value = "/modify.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modify(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		//获取页面参数
		String tcMasterId = request.getParameter("tcMasterId");
		String tcDetailId = request.getParameter("tcDetailId");
		String parkId = request.getParameter("parkId");
		String manageId = request.getParameter("manageId");
		String provinceCd = request.getParameter("provinceCd");
		String cityCd = request.getParameter("cityCd");
		String backReason = request.getParameter("backReason");
		String backDt = request.getParameter("backDt");
		String companyNm = request.getParameter("companyNm");
		String backPrice = request.getParameter("backPrice");
		String backQty = request.getParameter("backQty");
		String backAmt = request.getParameter("backAmt");
		String payeeAccNm = request.getParameter("payeeAccNm");
		String payeeAccNo = request.getParameter("payeeAccNo");
		String payeeBankNm = request.getParameter("payeeBankNm");
		String payeeBankNo = request.getParameter("payeeBankNo");
		String flag = request.getParameter("flag");//流程标识

        String channelId = request.getParameter("channelId");//渠道ID

		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		if(StringUtils.isEmpty(tcMasterId)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}
		AssTrailCarMVO entity = null;
		try {
			entity = new AssTrailCarMVO();
			entity.setId(Long.valueOf(tcMasterId));
			//判断是发起人,还是标记拖车状态的人
			if(StringUtils.isNotEmpty(flag)){
				if("12".equals(flag) || "8".equals(flag)){//修改停车场信息
					if(StringUtils.isNotEmpty(parkId)){
						entity.setParkId(Long.parseLong(parkId));
					}
					if(StringUtils.isNotEmpty(manageId)){
						entity.setManageId(Long.parseLong(manageId));
					}
					entity.setProvinceCd(provinceCd);
					entity.setCityCd(cityCd);
				}else if("2".equals(flag)){//修改拖车信息
					if(StringUtils.isNotEmpty(backDt)){
						entity.setBackDt(DateUtils.formatStringToDate(backDt, DateUtils.YYYY_MM_DD));
					}
					entity.setBackReason(backReason);
					entity.setCompanyNm(companyNm);
                    if(StringUtils.isNotEmpty(channelId)){
                        entity.setChannelId(Long.valueOf(channelId));
                    }
					entity.setPayeeAccNm(payeeAccNm);
					entity.setPayeeAccNo(payeeAccNo);
					entity.setPayeeBankNm(payeeBankNm);
					entity.setPayeeBankNo(payeeBankNo);
					getExtRequestParams(request, entity);
					//修改明细表中的拖车费用信息
					if(StringUtils.isEmpty(tcDetailId)){
						result.setSuccess(BaseConstant.IS_YESNO_NO);
						result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
						return result;
					}else{
						AssTrailCarDVO entity2 = new AssTrailCarDVO();
						entity2.setId(Long.valueOf(tcDetailId));
						if(StringUtils.isNotEmpty(backPrice)){//元转分
							Long price = DecimalUtils.convertYuanToFen(Double.valueOf(backPrice));
							entity2.setBackPrice(price);
							entity.setBackPrice(price);
						}
						if(StringUtils.isNotEmpty(backQty)){
							entity2.setBackQty(Integer.parseInt(backQty));
							entity.setBackQty(Integer.parseInt(backQty));
						}
						if(StringUtils.isNotEmpty(backAmt)){//元转分
							Long bakAmt = DecimalUtils.convertYuanToFen(Double.valueOf(backAmt));
							entity2.setBackAmt(bakAmt);
							entity.setBackAmt(bakAmt);
						}
						entity2.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
						entity2.setMdfTm(new Date());
						boolean success2 = this.assTrailCarDService.modify(entity2);
						if(!success2){
							result.setSuccess(BaseConstant.IS_YESNO_NO);
							result.setInfo(SysLogConstant.LOG_CMM_UPDATE_FAIL);
							BaseLogUtils.newLogger("修改拖车明细表失败").setKeys("tcDetailId:" + tcDetailId, "DATA:" + JSONObject.toJSONString(entity2)).info();
						}
					}
				}
			}
			//设置主表实体属性
			entity.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
			entity.setMdfTm(new Date());
			boolean success = this.assTrailCarMService.modify(entity);
			if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_UPDATE_FAIL);
                BaseLogUtils.newLogger("修改拖车主表失败").setKeys("tcMasterId:" + tcMasterId, "DATA:" + JSONObject.toJSONString(entity)).info();
			}
		}catch (BaseException ex) {
            BaseLogUtils.newLogger("修改拖车主表失败").setThrowable(ex).setKeys("tcMasterId:" + tcMasterId, "DATA:" + JSONObject.toJSONString(entity)).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
		}catch (Exception ex) {
            BaseLogUtils.newLogger("修改拖车主表失败").setThrowable(ex).setKeys("tcMasterId:" + tcMasterId, "DATA:" + JSONObject.toJSONString(entity)).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
		}
		return result;
	}
	
	/**
	 * 获取拖车申请主表信息-JL
	 */
	@RequestMapping(value = "/getTrailCarMaster.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getTrailCarMaster(HttpServletRequest request, HttpServletResponse response) {
		//获取页面参数
		String tcMasterId = request.getParameter("tcMasterId");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(tcMasterId)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}
		try {
			AssTrailCarMVO vo = this.assTrailCarMService.selectById(Long.valueOf(tcMasterId));
			if(null == vo){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				return result;
			}
			//返回一条数据
			result.setData(vo);
		}catch(BaseException ex) {
			BaseLogUtils.newLogger("获取拖车主表数据失败").setThrowable(ex).setKeys("tcMasterId:" + tcMasterId).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
			throw ex;
		}catch(Exception ex) {
            BaseLogUtils.newLogger("获取拖车主表数据失败").setThrowable(ex).setKeys("tcMasterId:" + tcMasterId).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
		}
		return result;
	}
	/**
	 * 获取拖车申请详细信息-JL
	 */
	@RequestMapping(value = "/getTrailCarDetail.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getTrailCarDetail(HttpServletRequest request, HttpServletResponse response) {
		//获取页面参数
		String tcMasterId = request.getParameter("tcMasterId");
		List<Long> ids = new ArrayList<Long>();
		List<AssTrailCarDVO> voList = new ArrayList<AssTrailCarDVO>();
		if(StringUtils.isEmpty(tcMasterId)){
			return null;
		}else{
			AssTrailCarDQueryCondition qc = new AssTrailCarDQueryCondition();
			qc.setMasterId(Long.valueOf(tcMasterId));
			qc.setIsDel(BaseConstant.IS_YESNO_NO);
			qc.setIsHis(BaseConstant.IS_YESNO_NO);
			voList = this.assTrailCarDService.searchDetailList(qc);
			//获取拖车详细信息IdList
			if(CollectionUtils.isNotEmpty(voList)){
				for (AssTrailCarDVO vo : voList) {
					ids.add(vo.getId());
				}
			}
		}
		try {
			List<AssTrailCarDVO> vo = this.assTrailCarDService.selectByDetailId(ids);
			if(CollectionUtils.isNotEmpty(vo) && CollectionUtils.isNotEmpty(voList)){
				for (AssTrailCarDVO aa : vo) {
					for (AssTrailCarDVO bb : voList) {
						if(aa.getId().equals(bb.getId())){
							aa.setCostFileRem(bb.getCostFileRem());
							break;
						}
					}
				}
			}
			if(null == vo){
			}else{
				//转成listPage-用于显示页面设备信息
				ListPageVO<AssTrailCarDVO> listPage = new ListPageVO<AssTrailCarDVO>(vo, vo.size());
				if(vo.size() > 0){
					//vo.get(0).setVoData(listPage);
				}
				return listPage;
			}
		}catch(BaseException ex) {
		    BaseLogUtils.newLogger("获取拖车申请明细失败").setThrowable(ex).setKeys("tcMasterId:" + tcMasterId).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
		    throw ex;
		}catch(Exception ex) {
            BaseLogUtils.newLogger("获取拖车申请明细失败").setThrowable(ex).setKeys("tcMasterId:" + tcMasterId).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
		}
		return null;
	}
	
	/**
	 * 初始化流程跟踪列表
	 */
	@RequestMapping(value = "/initFlowList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initFlowList(HttpServletRequest request, HttpServletResponse response) {
		//获取页面参数
		String tcMasterId = request.getParameter("tcMasterId");
		String tcDetailId = request.getParameter("tcDetailId");
		List<Long> dataIdList = new ArrayList<Long>();
		if(StringUtils.isNotEmpty(tcMasterId) && StringUtils.isNotEmpty(tcDetailId)){
			//获取拖车相关流程业务主键
			AssTrailCarDQueryCondition assTrailCarDQC = new AssTrailCarDQueryCondition();
			AssTrailCarDVO assTrailCarD = this.assTrailCarDService.selectById(Long.valueOf(tcDetailId));
			if(assTrailCarD != null && assTrailCarD.getPaySchId() != null){
				assTrailCarDQC.setPaySchId(assTrailCarD.getPaySchId());
				List<AssTrailCarDVO> trailList = this.assTrailCarDService.searchDetailList(assTrailCarDQC);
				if (trailList != null && trailList.size() > 0) {
					for (AssTrailCarDVO assTrailCarDVO : trailList) {
						if (assTrailCarDVO.getId() != null) {
							//拖车审批
							dataIdList.add(assTrailCarDVO.getMasterId());
							//拖车管理处置、优车处置
							AssDealSellQueryCondition assDealSellQC = new AssDealSellQueryCondition();
							assDealSellQC.setDetailId(assTrailCarDVO.getId());
							assDealSellQC.setMasterId(assTrailCarDVO.getMasterId());
							List<AssDealSellVO> sellList = this.assDealSellService.searchAssDealSellList(assDealSellQC);
							if (sellList != null && sellList.size() > 0) {
								for (AssDealSellVO assDealSellVO : sellList) {
									if (assDealSellVO.getId() != null) {
										dataIdList.add(assDealSellVO.getId());
									}
								}
							}
							//转优车
							AssDealCarQueryCondition assDealCarQC = new AssDealCarQueryCondition();
							assDealCarQC.setDetailId(assTrailCarDVO.getId());
							assDealCarQC.setMasterId(assTrailCarDVO.getMasterId());
							List<AssDealCarVO> dealCarList = this.assDealCarService.searchAssDealCarList(assDealCarQC);
							if (dealCarList != null && dealCarList.size() > 0) {
								for (AssDealCarVO assDealCarVO : dealCarList) {
									if (assDealCarVO.getId() != null) {
										dataIdList.add(assDealCarVO.getId());
									}
								}
							}
							//拖车赎回
							AssDealRedeemQueryCondition assDealRedeemQC = new AssDealRedeemQueryCondition();
							assDealRedeemQC.setDetailId(assTrailCarDVO.getId());
							assDealRedeemQC.setMasterId(assTrailCarDVO.getMasterId());
							List<AssDealRedeemVO> dealRedeemList = this.assDealRedeemService.searchAssDealRedeemList(assDealRedeemQC);
							if (dealRedeemList != null && dealRedeemList.size() > 0) {
								for (AssDealRedeemVO assDealRedeemVO : dealRedeemList) {
									if (assDealRedeemVO.getId() != null) {
										dataIdList.add(assDealRedeemVO.getId());
									}
								}
							}
						}
					}
				}
			}
		}
		SysFlowSHQueryCondition qc = new SysFlowSHQueryCondition();
		qc.setDataIdList(dataIdList);
		qc.setWordsInTheTable(InterfaceConstants.ASS_FLOW_S_H_ASS);
		qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
		//查询拖车相关历史流程
		List<SysFlowSHDTO> flowList = this.assTrailCarMService.searchFlowListPage(qc);
		//查询流程创建人姓名
		SysUsrVO usrVo = null;
		String sysCd = CurrentThreadContext.getCurrentSysCd();
		if(CollectionUtils.isNotEmpty(flowList) && flowList.size()>0){
			for(SysFlowSHDTO dto : flowList){
				usrVo = this.sysUsrService.selectById(dto.getCrtUsrId(), sysCd);
				dto.setCrtUsrName(usrVo.getRefRlNm());
			}
		}
		ListPageVO<SysFlowSHDTO> listPage = new ListPageVO<SysFlowSHDTO>(flowList, flowList.size());
		return listPage;
	}
	
	/**
	 * 到拖车管理-转优车申请页面
	 */
	@RequestMapping(value = "/toOptimalApplyPage.do", method = { RequestMethod.GET})
	public ModelAndView toOptimalApplyPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("ass/assTrailCarM/assOptimalApplyPage");
		String tcMasterId = request.getParameter("tcMasterId");
		String tcDetailId = request.getParameter("tcDetailId");
		String prjPrdDtlId = request.getParameter("prjPrdDtlId");
		String cstId = request.getParameter("cstId");
		String cstNm = request.getParameter("cstNm");
		String prjId = request.getParameter("prjId");
		String businessType = request.getParameter("businessType");
		String prjTypCd = request.getParameter("prjTypCd");
		String prjNm = request.getParameter("prjNm");
		String orgName = request.getParameter("orgName");
		String buOrgCd = request.getParameter("buOrgCd");
		String paySchId = request.getParameter("paySchId");
		String paySchNo = request.getParameter("paySchNo");
        if (StringUtils.isNotEmpty(prjId)) {
            boolean check = this.assTrailCarDService.checkCarIsChanging(Long.valueOf(prjId), Long.valueOf(prjPrdDtlId));
            if (check) {
                throw new BaseException("车辆换车中，不允许发起该流程");
            }
            PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(Long.valueOf(prjId));
            if (null != prjBscInfoVO) {
                // 判断是否资管业务
                Integer isInsBiz = prjBscInfoVO.getIsInsBiz();
                if (BaseConstant.IS_YESNO_YES == isInsBiz) {
                    // 资管业务
                    throw new BaseException("资管业务暂不支持发起拖车转优车");
                } else if (BaseConstant.IS_YESNO_NO == isInsBiz) {
                    // 非资管业务
                    List<PrjPrdPaySchMDTO> paySchMDTOS = this.prjPrdPaySchMApiService.selectEnabledListByPaySchId(Long.valueOf(paySchId));
                    if (CollectionUtils.isNotEmpty(paySchMDTOS)) {
                        PrjPrdPaySchMDTO dto = paySchMDTOS.get(0);
                        String enabledPaySchId = String.valueOf(dto.getId());
                        String enabledPaySchNo = dto.getPaySchNo();
                        view.addObject("enabledPaySchId", enabledPaySchId);
                        view.addObject("enabledPaySchNo", enabledPaySchNo);
                    }
                }
            }
        }
        boolean check = this.assTrailCarMService.checkDealOrTransUsedFlowStart(Long.valueOf(tcMasterId));
        if (false == check) {
            throw new BaseException("绑定未申请放款的车抵贷业务YQ项目，请先作废或放款");
        }
		AssTrailCarHvQueryCondition qc = new AssTrailCarHvQueryCondition();
		qc.setMasterId(Long.parseLong(tcMasterId));
		List<AssTrailCarHvVO> list = assTrailCarHvService.searchList(qc);
		if (CollectionUtils.isNotEmpty(list)) {
		    AssTrailCarHvVO vo = list.get(0);
		    if (StringUtils.isNotEmpty(vo.getCarNo())) {
                view.addObject("isNew", "1");
            }
        }
		//设置拖车主表ID和明细表ID值
		view.addObject("tcMasterId", tcMasterId);
		view.addObject("tcDetailId", tcDetailId);
		view.addObject("prjPrdDtlId", prjPrdDtlId);//项目产品明细表ID
		view.addObject("cstId", cstId);
		view.addObject("cstNm", cstNm);
		view.addObject("prjId", prjId);//项目基础信息表ID
		view.addObject("businessType", businessType);
		view.addObject("prjTypCd", prjTypCd);
		view.addObject("prjNm", prjNm);//项目名称
		view.addObject("orgName", orgName);//项目所属事业部名称
		view.addObject("buOrgCd", buOrgCd);//项目所属事业部简称
		view.addObject("paySchId", paySchId);//支付表ID
		view.addObject("paySchNo", paySchNo);//支付表号
		return view;
	}
	
	/**
	 * 到优车管理列表页面
	 */
	@RequestMapping(value = "/toOptimalListPage.do", method = { RequestMethod.GET})
	public ModelAndView toOptimalListPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("ass/assTrailCarM/assOptimalCarManager");
		String sysCd = CurrentThreadContext.getCurrentSysCd(); 
		String orgCd = CurrentThreadContext.getCurrentOrgCd();
		//获取处置状态
		List<KeyValueVO> dealStsList = this.assTrailCarMService.getKvList(InterfaceConstants.DEAL_STS_CD, sysCd, orgCd);
		//获取评价状态
		List<KeyValueVO> evalStsList = this.assTrailCarMService.getKvList(InterfaceConstants.EVAL_STATUS_CD, sysCd, orgCd);

		// 拍卖状态
		List<KeyValueVO> auctionStsList = this.assTrailCarMService.getKvList(AssDealSellConstant.AUCTION_STS_CD, sysCd, orgCd);
		// 到账状态
		List<KeyValueVO> toAccStsList = this.assTrailCarMService.getKvList(AssDealSellConstant.TO_ACC_STS_CD, sysCd, orgCd);
		// 诉讼状态
		List<KeyValueVO> lawsuitStsList = this.assTrailCarMService.getKvList(SueDicCode.SUE0007, sysCd, orgCd);


		view.addObject("dealStsList", dealStsList);
		view.addObject("evalStsList", evalStsList);
		view.addObject("auctionStsList", JSON.toJSONString(auctionStsList));
		view.addObject("toAccStsList", JSON.toJSONString(toAccStsList));
		view.addObject("lawsuitStsList", JSON.toJSONString(lawsuitStsList));
		return view;
	}
	
	/**
	 * 初始化优车管理列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/optimalInitList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object optimalInitList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}

		AssDealCarQueryCondition qc = this.initOptimalParam(request, response);
		page.setCondition(qc);
		
		Pager pager = this.assDealCarService.searchListPage(page);
		List<AssDealCarVO> list = (List<AssDealCarVO>) pager.getResultList();
		ListPageVO<AssDealCarVO> listPage = new ListPageVO<AssDealCarVO>(list, pager.getTotalCount());
		return listPage;
	}
	
	/**
	 * 初始化优车管理列表-获取查询参数
	 */
	public AssDealCarQueryCondition initOptimalParam(HttpServletRequest request, HttpServletResponse response) {
		//获取页面参数
		String cstNm = request.getParameter("cstNm");
		String paySchNo = request.getParameter("paySchNo");
		String dealStsCd = request.getParameter("dealStsCd");
		String evalStatusCd = request.getParameter("evalStatusCd");
		String isEnter = request.getParameter("isEnter");
		String isOut = request.getParameter("isOut");
		String minEnterTm = request.getParameter("minEnterTm");
		String maxEnterTm = request.getParameter("maxEnterTm");
		String minOutTm = request.getParameter("minOutTm");
		String maxOutTm = request.getParameter("maxOutTm");
		String isAssign = request.getParameter("isAssign");
		String auctionStsCd = request.getParameter("auctionStsCd");
		String toAccStsCd = request.getParameter("toAccStsCd");
		String sueStsCd = request.getParameter("sueStsCd");
		//选中行的支付表idList集合
		String pkIds = request.getParameter("pkIds");

		AssDealCarQueryCondition qc = new AssDealCarQueryCondition();
		if (StringUtils.isNotEmpty(cstNm)) {//客户名称
			qc.setCstNm(cstNm);
		}
		if (StringUtils.isNotEmpty(paySchNo)) {//支付表号
			qc.setPaySchNo(paySchNo);
		}
		if (StringUtils.isNotEmpty(dealStsCd)) {//处置状态
			qc.setDealStsCd(dealStsCd);
		}
		if (StringUtils.isNotEmpty(evalStatusCd)) {//评估状态
			qc.setEvalStatusCd(evalStatusCd);
		}
		if (StringUtils.isNotEmpty(isEnter)) {//是否入库
			qc.setIsEnter(Integer.parseInt(isEnter));
		}
		if (StringUtils.isNotEmpty(isOut)) {//是否出库
			qc.setIsOut(Integer.parseInt(isOut));
		}
		if (StringUtils.isNotEmpty(minEnterTm)) {//入库时间-开始
			qc.setMinEnterTm(DateUtils.formatStringToDate(minEnterTm, DateUtils.YYYY_MM_DD));
		}
		if (StringUtils.isNotEmpty(maxEnterTm)) {//入库时间-结束
			qc.setMaxEnterTm(DateUtils.formatStringToDate(maxEnterTm, DateUtils.YYYY_MM_DD));
		}

		if (StringUtils.isNotEmpty(minOutTm)) {//出库时间-开始
			qc.setMinOutTm(DateUtils.formatStringToDate(minOutTm, DateUtils.YYYY_MM_DD));
		}
		if (StringUtils.isNotEmpty(maxOutTm)) {//出库时间-结束
			qc.setMaxOutTm(DateUtils.formatStringToDate(maxOutTm, DateUtils.YYYY_MM_DD));
		}
		if (StringUtils.isNotEmpty(isAssign)) {//是否可过户
			qc.setIsAssign(Integer.parseInt(isAssign));
		}
		if (StringUtils.isNotEmpty(auctionStsCd)) {// 拍卖状态
			qc.setAuctionStsCd(auctionStsCd);
		}
		if (StringUtils.isNotEmpty(toAccStsCd)) {// 到账状态
			qc.setToAccStsCd(toAccStsCd);
		}
		if (StringUtils.isNotEmpty(sueStsCd)) {// 诉讼状态
			qc.setSueStsCd(sueStsCd);
		}
		//要导出的优车信息关联的支付表idList集合
		if(StringUtils.isNotEmpty(pkIds)){
			List<String> pkIdsList = new ArrayList<String>();
			JSONArray pkIdsArray = JSONArray.fromObject(pkIds);
			for (Object object : pkIdsArray) {
				pkIdsList.add(object.toString());
			}
			qc.setPkIdsList(pkIdsList);
		}
		qc.setUsrId(CurrentThreadContext.getCurrentUserId());
		qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
		return qc;
	}
	
	/**
	 * 到优车管理-优车处置申请页面
	 */
	@RequestMapping(value = "/toYCDealApplyPage.do", method = { RequestMethod.GET})
	public ModelAndView toYCDealApplyPage(HttpServletRequest request, HttpServletResponse response) {
		// 校验诉讼状态
		String sueApplyId = request.getParameter("sueApplyId");
//		if (StringUtils.isNotEmpty(sueApplyId) && !"null".equals(sueApplyId	)) {
//			assDealSellService.checkLawsuitSts(Long.parseLong(sueApplyId));
//		}

		ModelAndView view = new ModelAndView("ass/assTrailCarM/assYCDealApplyPage");
		String tcMasterId = request.getParameter("tcMasterId");
		String tcDetailId = request.getParameter("tcDetailId");
		String optimal_Id = request.getParameter("optimal_Id");
		String prjPrdDtlId = request.getParameter("prjPrdDtlId");
		String cstId = request.getParameter("cstId");
		String cstNm = request.getParameter("cstNm");
		String orgName = request.getParameter("orgName");
		String buOrgCd = request.getParameter("buOrgCd");
		String backedFlagCd = request.getParameter("backedFlagCd");
		String prjId = request.getParameter("prjId");
		String businessType = request.getParameter("businessType");
		String prjTypCd = request.getParameter("prjTypCd");
		String prjNm = request.getParameter("prjNm");
		String sysCd = CurrentThreadContext.getCurrentSysCd(); 
		String orgCd = CurrentThreadContext.getCurrentOrgCd();
        String auctionStsCdNm = request.getParameter("auctionStsCdNm");
        boolean check = this.assTrailCarDService.checkCarIsChanging(Long.valueOf(prjId), Long.valueOf(prjPrdDtlId));
        if (check) {
            throw new BaseException("车辆换车中，不允许发起该流程");
        }
        // 根据拖车明细里的支付表（启用）查我司支付表
        if (StringUtils.isNotEmpty(tcDetailId)) {
            AssTrailCarDVO assTrailCarDVO = this.assTrailCarDService.selectById(Long.valueOf(tcDetailId));
            if (StringUtils.isNotEmpty(assTrailCarDVO.getPaySchId())) {
                List<PrjPrdPaySchMDTO> prjPrdPaySchMDTOS = this.prjPrdPaySchMApiService.searchTheSamePrdOtherPaySchMList(Long.valueOf(assTrailCarDVO.getPaySchId()));
                if (CollectionUtils.isNotEmpty(prjPrdPaySchMDTOS)) {
                    for (PrjPrdPaySchMDTO prjPrdPaySchMDTO : prjPrdPaySchMDTOS) {
                        if (PrjPrdPaySchMConstant.PAY_SCH_TYP_CD_WS.equals(prjPrdPaySchMDTO.getPaySchTypCd())) {
                            view.addObject("wsPaySchId", prjPrdPaySchMDTO.getId());
                            view.addObject("wsPaySchNo", prjPrdPaySchMDTO.getPaySchNo());
                        }
                    }
                }
            }
        }
        check = this.assTrailCarMService.checkDealOrTransUsedFlowStart(Long.valueOf(tcMasterId));
        if (false == check) {
            throw new BaseException("绑定未申请放款的车抵贷业务YQ项目，请先作废或放款");
        }
        // 提前获取优车数据id
        Long ycSellId = sysSequenceApiService.getFun("FN_GEN_ASS_DEAL_SELL_ID");
        //处置接收人类型
		List<KeyValueVO> buyerTypeList = this.assTrailCarMService.getKvList(InterfaceConstants.BUYER_TYPE_CD, sysCd, orgCd);
		view.addObject("buyerTypeList", buyerTypeList);
		//处置路径
		List<KeyValueVO> sellChannelList = this.assTrailCarMService.getKvList(InterfaceConstants.SELL_CHANNEL_CD, sysCd, orgCd);
		view.addObject("sellChannelList", sellChannelList);
		//数据类型
		List<KeyValueVO> dataTypeList = this.assTrailCarMService.getKvList(InterfaceConstants.DATA_TYPE_CD_SY, sysCd, orgCd);
		view.addObject("dataTypeList", dataTypeList);
		//设置拖车主表ID和明细表ID值
		view.addObject("tcMasterId", tcMasterId);
		view.addObject("tcDetailId", tcDetailId);
		view.addObject("optimal_Id", optimal_Id);
        view.addObject("ycSellId", ycSellId);
		view.addObject("prjPrdDtlId", prjPrdDtlId);//项目产品明细表ID
		view.addObject("cstId", cstId);
		view.addObject("cstNm", cstNm);
		view.addObject("orgName", orgName);
		view.addObject("buOrgCd", buOrgCd);
		view.addObject("backedFlagCd", backedFlagCd);
		view.addObject("prjId", prjId);//项目基础信息表ID
		view.addObject("businessType", businessType);
		view.addObject("prjTypCd", prjTypCd);
		view.addObject("prjNm", prjNm);//项目名称
		view.addObject("sysDate", DateUtils.formatDateToString(new Date(), DateUtils.YYYY_MM_DD));
		view.addObject("applyNm", CurrentThreadContext.getCurrentUserName());
		view.addObject("sueApplyId", sueApplyId);
		view.addObject("auctionStsCdNm", auctionStsCdNm);
		return view;
	}
	
	/**
	 * 导出拖车申请列表信息
	 * 导出拖车管理列表信息
	 * 导出优车管理列表信息
	 */
	@RequestMapping(value = "/exportAssInfo.do", method = { RequestMethod.POST,RequestMethod.GET })
	@ResponseBody
	public Object exportAssInfo(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_BK_EXPORT_SUCC);
		String eFlag = request.getParameter("eFlag");//导出标识
		String orgCd = CurrentThreadContext.getCurrentOrgCd();
		if(StringUtils.isEmpty(eFlag)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_PARAM_IS_BAD);
			return result;
		}
		AssTrailCarDQueryCondition qc1 = null;
		AssDealCarQueryCondition qc2 = null;
		AssTrailCarHvQueryCondition qc3 = null;
		try {
			// 获取查询条件
			if(eFlag.equals("tcsq") || eFlag.equals("tcgl")){//拖车申请和拖车管理
				qc1 = this.initTrailParam(request, response);
			}else if(eFlag.equals("ycgl")){//优车管理
				qc2 = this.initOptimalParam(request, response);
			}else if(eFlag.equals("kggl")){//库管管理
				qc3 = this.initTrailCarHvParam(request, response);
			}
			String path = this.assTrailCarMService.exportAssInfo(qc1, qc2,qc3, orgCd, eFlag);
			if(StringUtils.isNotEmpty(path)){
				result.setSuccess(BaseConstant.IS_YESNO_YES);
				result.setInfo(SysLogConstant.LOG_BK_EXPORT_SUCC);
				result.setData(path);
			}
		} catch (BaseException ex) {
			BaseLogUtils.newLogger("导出拖车模块数据失败").setThrowable(ex).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
			throw ex;
		} catch (Exception ex) {
            BaseLogUtils.newLogger("导出拖车模块数据失败").setThrowable(ex).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
		}
		
		return result;
	}
	
	/**
	 * 初始化文件列表
	 */
	@RequestMapping(value = "/initFilesList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initFilesList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String pkId = request.getParameter("pkId");
		String tabNm = request.getParameter("tabNm");
		String pkIdList = request.getParameter("pkIdList");//主键List
		String flag = request.getParameter("flag");
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}

		SysUlFilesRecQueryCondition qc = new SysUlFilesRecQueryCondition();
		if ((StringUtils.isEmpty(pkId) && StringUtils.isEmpty(pkIdList))||StringUtils.isEmpty(tabNm)) {
			return page;
		}
		//判断此次传参是否为主键List
		if (StringUtils.isNotEmpty(pkIdList)) {
			pkIdList = pkIdList.substring(1, pkIdList.length()-1);
		    String[] arr = pkIdList.split(", ");
		    List<String> pkList = java.util.Arrays.asList(arr);
			qc.setPkIdList(pkList);
		}else{
			qc.setPkId(pkId);
		}
		//判断标识确定文件配置编码
		if (StringUtils.isNotEmpty(flag)) {
			if("tccfj".equals(flag) || "tcclsfj".equals(flag)){//停车场附件
				qc.setCfgDtlCd(AssFileConstant.ASS_PARKING_CFGDTLCD_10);
			}else if("tcsq".equals(flag)){//拖车申请
				qc.setCfgDtlCd(AssFileConstant.ASS_TRAIL_CAR_CFGDTLCD_20);
			}else if("rkd".equals(flag) || "crkzl".equals(flag)){//入库单-出入库资料
				qc.setCfgDtlCd(AssFileConstant.ASS_TRAIL_CAR_CFGDTLCD_30);
			}else if("ckd".equals(flag)){//出库单
				qc.setCfgDtlCd(AssFileConstant.ASS_TRAIL_CAR_CFGDTLCD_40);
			}else if("jjd".equals(flag)){//交接单
				qc.setCfgDtlCd(AssFileConstant.ASS_TRAIL_CAR_CFGDTLCD_50);
			}else if("tccz".equals(flag)){//处置申请
				qc.setCfgDtlCd(AssFileConstant.ASS_TRAIL_CAR_CFGDTLCD_60);
			}else if("cztcr".equals(flag)){//处置-提车人
				qc.setCfgDtlCd(AssFileConstant.ASS_TRAIL_CAR_CFGDTLCD_70);
			}else if("tcsh".equals(flag)){//赎回申请
				qc.setCfgDtlCd(AssFileConstant.ASS_TRAIL_CAR_CFGDTLCD_80);
			}else if("shtcr".equals(flag)){//赎回-提车人
				qc.setCfgDtlCd(AssFileConstant.ASS_TRAIL_CAR_CFGDTLCD_90);
			}else if("zycsq".equals(flag)){//转优车申请
				qc.setCfgDtlCd(AssFileConstant.ASS_TRAIL_CAR_CFGDTLCD_100);
			}else if("lkpz_tc".equals(flag)||"lkpz_cz".equals(flag)||"lkpz_sh".equals(flag)){//来款凭证
				qc.setCfgDtlCd(AssFileConstant.ASS_TRAIL_CAR_CFGDTLCD_110);
			}

		}
		qc.setCfgCd(AssFileConstant.ASS_TRAIL_CAR_CFGCD);//ASS001-拖车模块
        if ("tcsq_hj".equals(flag)) {
            qc.setCfgCd(AssFileConstant.ASS_HANJIAN_FILE_CFG_CD);
            qc.setCfgDtlCd(AssFileConstant.ASS_HANJIAN_CFGDTLCD_1);
        }
		qc.setTabNm(tabNm);
		qc.setSysCd(CurrentThreadContext.getCurrentSysCd());//系统代码-必须条件
		page.setCondition(qc);
		
		List<SysUlFilesRecVO> list = this.sysUlFilesRecService.searchList(qc);
		//如果文件标识是"出入库资料",默认先查出入库单,下面继续查询出库单,然后合并.
		if (StringUtils.isNotEmpty(flag) && "crkzl".equals(flag)) {
			qc.setCfgDtlCd(AssFileConstant.ASS_TRAIL_CAR_CFGDTLCD_40);
			List<SysUlFilesRecVO> list2 = this.sysUlFilesRecService.searchList(qc);
			list.addAll(list2);//合并列表
		}
		//遍历list查询文件上传者-真实姓名
		SysUsrVO usrVo = null;
		AssParkingValidVO validVo = null;
		String sysCd = CurrentThreadContext.getCurrentSysCd();
		if(CollectionUtils.isNotEmpty(list) && list.size()>0){
			for(SysUlFilesRecVO vo : list){
				usrVo = this.sysUsrService.selectById(vo.getCrtUsrId(), sysCd);
				vo.setCrtUsrRlNm(usrVo.getRefRlNm());
				if("tcclsfj".equals(flag)){//停车场合同有效期
					validVo = this.assParkingValidService.selectById(Long.parseLong(vo.getPkId()));
					vo.setBeginDt(validVo.getBeginDt());
					vo.setEndDt(validVo.getEndDt());
				}
			}
		}
		page.setResultList(list);
		page.setTotalCount(list.size());
		
		ListPageVO<SysUlFilesRecVO> listPage = new ListPageVO<SysUlFilesRecVO>(list, list.size());
		return listPage;
	}

    /**
     * 到拖车模块-入库单信息页面
     */
    @RequestMapping(value = "/toWarehousePage.do", method = { RequestMethod.GET, RequestMethod.POST })
    public ModelAndView toWarehousePage(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        //获取流程传过来的参数：拖车主表ID和明细表ID
        String tcMasterId = request.getParameter("tcMasterId");
        String tcDetailId = request.getParameter("tcDetailId");
        // 启用的支付表id(优车处申请和流程附加页面传过来的就是我司支付表)
        String paySchId = request.getParameter("paySchId");
        String paySchNo = request.getParameter("paySchNo");
        String prjId = request.getParameter("prjId");
        String crflag = request.getParameter("crflag");
        String isNew = request.getParameter("isNew");
        AssTrailCarHvQueryCondition qc = new AssTrailCarHvQueryCondition();
        qc.setMasterId(Long.parseLong(tcMasterId));
        List<AssTrailCarHvVO> list = assTrailCarHvService.searchList(qc);
        if (CollectionUtils.isNotEmpty(list)) {
            AssTrailCarHvVO vo = list.get(0);
            if (StringUtils.isNotEmpty(vo.getCarNo())) {
                isNew = "1";
            }
        }
        ModelAndView view = null;
        if ("1".equals(isNew)) {
            view = new ModelAndView("ass/assTrailCarD/newAssEntryOrderEdit");
            view.addObject("shiftModeKV", JSON.toJSONString(sysDictionaryApiService.getKvList(DictionaryConstant.CODE_PRD_HUANDFS_CD, "15000", "0000")));
            view.addObject("styleDriveModeKV", JSON.toJSONString(sysDictionaryApiService.getKvList(DictionaryConstant.CODE_PRD_QUDONG_CD, "15000", "0000")));
            view.addObject("emissionStandardKV", JSON.toJSONString(sysDictionaryApiService.getKvList(DictionaryConstant.CODE_PRD_PAIFANGBZ_CD, "15000", "0000")));
            view.addObject("fuelTypeKV", JSON.toJSONString(sysDictionaryApiService.getKvList(DictionaryConstant.CODE_PRD_RANLIAO_CD, "15000", "0000")));
        } else {
            view = new ModelAndView("ass/assTrailCarD/assEntryOrderEdit");
        }
        // 根据启用支付表id找我司支付表id
        if (StringUtils.isNotEmpty(paySchId)) {
            List<PrjPrdPaySchMDTO> prjPrdPaySchMDTOS = this.prjPrdPaySchMApiService.searchTheSamePrdOtherPaySchMList(Long.valueOf(paySchId));
            if (CollectionUtils.isNotEmpty(prjPrdPaySchMDTOS)) {
                for (PrjPrdPaySchMDTO prjPrdPaySchMDTO : prjPrdPaySchMDTOS) {
                    if (PrjPrdPaySchMConstant.PAY_SCH_TYP_CD_WS.equals(prjPrdPaySchMDTO.getPaySchTypCd())) {
                        view.addObject("wsPaySchId", prjPrdPaySchMDTO.getId());
                        view.addObject("wsPaySchNo", prjPrdPaySchMDTO.getPaySchNo());
                    }
                }
            }
        }
        view.addObject("tcMasterId", tcMasterId);
        view.addObject("tcDetailId", tcDetailId);
        view.addObject("paySchId", paySchId);
        view.addObject("paySchNo", paySchNo);
        view.addObject("prjId", prjId);
        view.addObject("crflag", crflag);
        view.addObject("isNew", isNew);
        view.addObject("sysDate", DateUtils.formatDateToString(new Date(), DateUtils.YYYY_MM_DD));
        view.addObject("loginUsrNm", CurrentThreadContext.getCurrentUserName());
        return view;
    }
	
	/**
	 * 获取拖车交接单客户端数据
	 */
	public AssTrailCarHvVO initWarehouseParam(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		//获取页面参数
		String tcMasterId = request.getParameter("tcMasterId");
		String tcDetailId = request.getParameter("tcDetailId");
		String prjId = request.getParameter("prjId");
		// 入库交接单挂在我司支付表下
		String paySchId = request.getParameter("wsPaySchId");
		String paySchNo = request.getParameter("wsPaySchNo");
		String carCl = request.getParameter("carCl");
		String carLen = request.getParameter("carLen");
		String tokenMileage = request.getParameter("tokenMileage");
		String plateNumber = request.getParameter("plateNumber");
		String isRun = request.getParameter("isRun");
		String isLicense = request.getParameter("isLicense");
		String isCertificate = request.getParameter("isCertificate");
		String isKey = request.getParameter("isKey");
		String isQuality = request.getParameter("isQuality");
		String isIns = request.getParameter("isIns");
		String insDt = request.getParameter("insDt");
		String otherRem = request.getParameter("otherRem");
		String tyreShouldQty = request.getParameter("tyreShouldQty");
		String tyreNormalQty = request.getParameter("tyreNormalQty");
		String tyreDamageQty = request.getParameter("tyreDamageQty");
		String tyreDefectQty = request.getParameter("tyreDefectQty");
		String tyreSpareQty = request.getParameter("tyreSpareQty");
		String gpsCardNo = request.getParameter("gpsCardNo");
		String isDamage = request.getParameter("isDamage");
		String damageRem = request.getParameter("damageRem");
		String handoverNm = request.getParameter("handoverNm");
		String receiverNm = request.getParameter("receiverNm");
		String handoverDt = request.getParameter("handoverDt");
		String receiverDt = request.getParameter("receiverDt");
		String handoverRem = request.getParameter("handoverRem");
		//完善信息部分
		String illegalOne = request.getParameter("illegalOne");//1分
		String illegalTwo = request.getParameter("illegalTwo");//2分
		String illegalThree = request.getParameter("illegalThree");//总分
		String illegalSix = request.getParameter("illegalSix");
		String illegalTwelve = request.getParameter("illegalTwelve");
		String illegalCount = request.getParameter("illegalCount");//总计分
		String illegalOther = request.getParameter("illegalOther");
		String isTransfer = request.getParameter("isTransfer");
		String isCmIns = request.getParameter("isCmIns");
		String cmInsDt = request.getParameter("cmInsDt");
		String isAccident = request.getParameter("isAccident");
		String emiStd = request.getParameter("emiStd");
		String engBrand = request.getParameter("engBrand");
		String engMdl = request.getParameter("engMdl");
		String hp = request.getParameter("hp");
		String bridge = request.getParameter("bridge");
		String playingDt = request.getParameter("playingDt");
		String licDt = request.getParameter("licDt");
		String carAnnualDt = request.getParameter("carAnnualDt");
		String certificateAnnualDt = request.getParameter("certificateAnnualDt");

		String carLevel = request.getParameter("carLevel");// 车辆等级
		String refrigeratorBrand = request.getParameter("refrigeratorBrand");// 冷藏车冷机品牌
		String stirLength = request.getParameter("stirLength");// 搅拌罐整车车长

		String carNo = request.getParameter("carNo"); // 车源编号
		String gpsNo = request.getParameter("gpsCardNo"); // gps卡号
		String yearChkDt = request.getParameter("asTm"); // 车辆年检日
		AssTrailCarHvVO entity = new AssTrailCarHvVO();
		try {
			//设置主表实体属性
			if(StringUtils.isNotEmpty(tcMasterId)){
				entity.setMasterId(Long.parseLong(tcMasterId));
			}
			if(StringUtils.isNotEmpty(tcDetailId)){
				entity.setDetailId(Long.parseLong(tcDetailId));
			}
			if(StringUtils.isNotEmpty(prjId)){
				entity.setPrjId(Long.parseLong(prjId));
			}
			if(StringUtils.isNotEmpty(paySchId)){
				entity.setPaySchId(Long.parseLong(paySchId));
			}
			if(StringUtils.isNotEmpty(isRun)){
				entity.setIsRun(Integer.parseInt(isRun));
			}
			if(StringUtils.isNotEmpty(isLicense)){
				entity.setIsLicense(Integer.parseInt(isLicense));
			}
			if(StringUtils.isNotEmpty(isCertificate)){
				entity.setIsCertificate(Integer.parseInt(isCertificate));
			}
			if(StringUtils.isNotEmpty(isKey)){
				entity.setIsKey(Integer.parseInt(isKey));
			}
			if(StringUtils.isNotEmpty(isQuality)){
				entity.setIsQuality(Integer.parseInt(isQuality));
			}
			if(StringUtils.isNotEmpty(isIns)){
				entity.setIsIns(Integer.parseInt(isIns));
			}
			if(StringUtils.isNotEmpty(insDt)){
				entity.setInsDt(DateUtils.formatStringToDate(insDt, DateUtils.YYYY_MM_DD));
			}
			//轮胎信息
			if(StringUtils.isNotEmpty(tyreShouldQty)){
				entity.setTyreShouldQty(Integer.parseInt(tyreShouldQty));
			}
			if(StringUtils.isNotEmpty(tyreNormalQty)){
				entity.setTyreNormalQty(Integer.parseInt(tyreNormalQty));
			}
			if(StringUtils.isNotEmpty(tyreDamageQty)){
				entity.setTyreDamageQty(Integer.parseInt(tyreDamageQty));
			}
			if(StringUtils.isNotEmpty(tyreDefectQty)){
				entity.setTyreDefectQty(Integer.parseInt(tyreDefectQty));
			}
			if(StringUtils.isNotEmpty(tyreSpareQty)){
				entity.setTyreSpareQty(Integer.parseInt(tyreSpareQty));
			}
			if(StringUtils.isNotEmpty(isDamage)){
				entity.setIsDamage(Integer.parseInt(isDamage));
			}
			if(StringUtils.isNotEmpty(handoverDt)){
				entity.setHandoverDt(DateUtils.formatStringToDate(handoverDt, DateUtils.YYYY_MM_DD));
			}
			if(StringUtils.isNotEmpty(receiverDt)){
				entity.setReceiverDt(DateUtils.formatStringToDate(receiverDt, DateUtils.YYYY_MM_DD));
			}
			entity.setPaySchNo(paySchNo);
			entity.setCarCl(carCl);
			entity.setCarLen(carLen);
			entity.setTokenMileage(tokenMileage);
			entity.setPlateNumber(plateNumber);
			entity.setOtherRem(otherRem);
			entity.setGpsCardNo(gpsCardNo);
			entity.setDamageRem(damageRem);
			entity.setHandoverNm(handoverNm);
			entity.setReceiverNm(receiverNm);
			entity.setHandoverRem(handoverRem);
			//完善信息
			entity.setIllegalOne(illegalOne);
			entity.setIllegalTwo(illegalTwo);
			entity.setIllegalCount(illegalCount);
			entity.setIllegalThree(illegalThree);
			entity.setIllegalSix(illegalSix);
			entity.setIllegalTwelve(illegalTwelve);
			entity.setIllegalOther(illegalOther);
			entity.setEmiStd(emiStd);
			entity.setEngBrand(engBrand);
			entity.setEngMdl(engMdl);
			entity.setHp(hp);
			entity.setBridge(bridge);
			if(StringUtils.isNotEmpty(isTransfer)){
				entity.setIsTransfer(Integer.parseInt(isTransfer));
			}
			if(StringUtils.isNotEmpty(isCmIns)){
				entity.setIsCmIns(Integer.parseInt(isCmIns));
			}
			if(StringUtils.isNotEmpty(isAccident)){
				entity.setIsAccident(Integer.parseInt(isAccident));
			}
			//日期转换
			if(StringUtils.isNotEmpty(cmInsDt)){
				entity.setCmInsDt(DateUtils.formatStringToDate(cmInsDt, DateUtils.YYYY_MM_DD));
			}
			if(StringUtils.isNotEmpty(playingDt)){
				entity.setPlayingDt(DateUtils.formatStringToDate(playingDt, DateUtils.YYYY_MM_DD));
			}
			if(StringUtils.isNotEmpty(licDt)){
				entity.setLicDt(DateUtils.formatStringToDate(licDt, DateUtils.YYYY_MM_DD));
			}
			if(StringUtils.isNotEmpty(carAnnualDt)){
				entity.setCarAnnualDt(DateUtils.formatStringToDate(carAnnualDt, DateUtils.YYYY_MM_DD));
			}
			if(StringUtils.isNotEmpty(certificateAnnualDt)){
				entity.setCertificateAnnualDt(DateUtils.formatStringToDate(certificateAnnualDt, DateUtils.YYYY_MM_DD));
			}
			if(StringUtils.isNotEmpty(carLevel)){
				entity.setCarLevel(Long.valueOf(carLevel));
			}
			if(StringUtils.isNotEmpty(refrigeratorBrand)){
				entity.setRefrigeratorBrand(refrigeratorBrand);
			}
			if(StringUtils.isNotEmpty(stirLength)){
				entity.setStirLength(stirLength);
			}
			if(StringUtils.isNotEmpty(carNo)){
				entity.setCarNo(carNo);
			}
			if(StringUtils.isNotEmpty(gpsNo)){
				entity.setGpsNo(gpsNo);
			}
			if(StringUtils.isNotEmpty(yearChkDt)){
				entity.setYearChkDt(yearChkDt);
			}
		}catch (BaseException ex) {
		    BaseLogUtils.newLogger("获取拖车交接单客户端数据失败").setThrowable(ex).setKeys("DATA:" + JSONObject.toJSONString(entity)).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
		    throw ex;
		}catch (Exception ex) {
            BaseLogUtils.newLogger("获取拖车交接单客户端数据失败").setThrowable(ex).setKeys("DATA:" + JSONObject.toJSONString(entity)).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
		}
		return entity;
	}
	
	/**
	 * 新增拖车交接单数据
	 */
	@RequestMapping(value = "/addWarehouseInfo.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object addWarehouseInfo(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		//设置返回参数
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		AssTrailCarHvVO entity = this.initWarehouseParam(request, response);
		try {
			entity.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
			entity.setCrtTm(new Date());
			entity.setIsDel(BaseConstant.IS_YESNO_NO);
			//保存拖车交接单信息
			Long id = this.assTrailCarHvService.add(entity);
			result.setData(id);
		}catch (BaseException ex) {
			BaseLogUtils.newLogger("新增拖车交接单信息数据失败").setThrowable(ex).setKeys("DATA:" + JSONObject.toJSONString(entity)).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
			throw ex;
		}catch (Exception ex) {
            BaseLogUtils.newLogger("新增拖车交接单信息数据失败").setThrowable(ex).setKeys("DATA:" + JSONObject.toJSONString(entity)).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
		}
		return result;
	}

    /**
     * 获取车型库信息
     */
    @RequestMapping(value = "/initVehData.do", method = { RequestMethod.GET})
    @ResponseBody
    public Object initVehData(HttpServletRequest request, HttpServletResponse response) {
        //获取页面参数
        String vin = request.getParameter("vin");
        String tcDetailId = request.getParameter("tcDetailId");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
        if(StringUtils.isEmpty(tcDetailId)){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            return result;
        }
        if(StringUtils.isEmpty(vin)){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            return result;
        }
        VehSrcInfDTO vehSrcInfDTO = null;
        List<AssTrailCarHvVO> assTrailCarHvVOS = null;
        try {
            Map<String, Object> data = new HashedMap();
            // 是否是新的入库交接单 1：是；其他：不是
            String isNew = request.getParameter("isNew");
            List<VehSrcInfDTO> vehSrcInfDTOS = null;
            if ("1".equals(isNew)) {
                if (StringUtils.isNotEmpty(vin)) {
                    // 车型
                    VehSrcInfQC qc = new VehSrcInfQC();
                    qc.setVin(vin);
                    vehSrcInfDTOS = vehSrcInfQueryApiService.searchVehSrcInfDTOList(qc);
                    if (CollectionUtils.isNotEmpty(vehSrcInfDTOS)) {
                        vehSrcInfDTO = vehSrcInfDTOS.get(0);
                        Long vehId = vehSrcInfDTO.getId();
                        vehSrcInfDTO = vehSrcInfQueryApiService.selectVehSrcInfDTOById(vehId);
                    }
                }
            }
            AssTrailCarHvQueryCondition qc = new AssTrailCarHvQueryCondition();
            qc.setDetailId(Long.valueOf(tcDetailId));
            assTrailCarHvVOS = assTrailCarHvService.searchList(qc);
            AssTrailCarHvVO assTrailCarHvVO = null;
            if (CollectionUtils.isNotEmpty(assTrailCarHvVOS)) {
                assTrailCarHvVO = assTrailCarHvVOS.get(0);
            }
            if (null != vehSrcInfDTO) {
                if (null != assTrailCarHvVO) {
                    if (!"".equals(assTrailCarHvVO.getCarNo()) && null != assTrailCarHvVO.getCarNo()) {
                        vehSrcInfDTO.setCarNo(assTrailCarHvVO.getCarNo());
                    }
                    if (!"".equals(assTrailCarHvVO.getYearChkDt()) && null != assTrailCarHvVO.getYearChkDt()) {
                        vehSrcInfDTO.setAsTm(DateUtils.formatStringToDate(assTrailCarHvVO.getYearChkDt(), DateUtils.YYYY_MM_DD));
                    }
                }
            }
            if (null != assTrailCarHvVO) {
                data.put("assTrailCarHv", assTrailCarHvVO);
            } else {
                data.put("assTrailCarHv", new AssTrailCarHvVO());
            }
            if (null != vehSrcInfDTO) {
                data.put("vehSrcInf", vehSrcInfDTO);
            } else {
                data.put("vehSrcInf", new VehSrcInfDTO());
            }
            BaseLogUtils.newLogger("获取车型库信息").setKeys("DATA:" + JSON.toJSONString(data)).info();
            result.setData(data);
        }catch(BaseException ex) {
            BaseLogUtils.newLogger("获取车型库信息失败").setThrowable(ex).setKeys("tcDetailId:" + tcDetailId).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
        }catch(Exception ex) {
            BaseLogUtils.newLogger("获取车型库信息失败").setThrowable(ex).setKeys("tcDetailId:" + tcDetailId).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
        }
        return result;
    }
	
	/**
	 * 获取拖车交接单-主表信息
	 */
	@RequestMapping(value = "/getHvInfoByDetailId.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getHvInfoByDetailId(HttpServletRequest request, HttpServletResponse response) {
		//获取页面参数
		String tcDetailId = request.getParameter("tcDetailId");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(tcDetailId)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}
		AssTrailCarHvQueryCondition qc = new AssTrailCarHvQueryCondition();
		try {
			qc.setDetailId(Long.valueOf(tcDetailId));
			List<AssTrailCarHvVO> vo = this.assTrailCarHvService.searchList(qc);
			if(null == vo){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
			}else{
				if(vo.size()>0){
					result.setData(vo.get(0));
				}else{
					result.setData(vo);
				}
			}
		}catch(BaseException ex) {
			BaseLogUtils.newLogger("获取拖车交接单数据失败").setThrowable(ex).setKeys("tcDetailId:" + tcDetailId).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
			throw ex;
		}catch(Exception ex) {
            BaseLogUtils.newLogger("获取拖车交接单数据失败").setThrowable(ex).setKeys("tcDetailId:" + tcDetailId).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
		}
		return result;
	}
	
	/**
	 * 修改拖车交接单数据
	 */
	@RequestMapping(value = "/modifyWarehouseInfo.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modifyWarehouseInfo(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		//获取页面参数
		String tcHvId = request.getParameter("tcHvId");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		if(StringUtils.isEmpty(tcHvId)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}
		AssTrailCarHvVO entity = this.initWarehouseParam(request, response);
		try {
			entity.setId(Long.parseLong(tcHvId));
			entity.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
			entity.setMdfTm(new Date());
			//保存拖车交接单信息
			boolean success = this.assTrailCarHvService.modify(entity);
			if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_UPDATE_FAIL);
			}
		}catch (BaseException ex) {
			BaseLogUtils.newLogger("修改拖车交接单数据失败").setThrowable(ex).setKeys("id:" + tcHvId,  "DATA:" + JSONObject.toJSONString(entity)).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
			throw ex;
		}catch (Exception ex) {
            BaseLogUtils.newLogger("修改拖车交接单数据失败").setThrowable(ex).setKeys("id:" + tcHvId,  "DATA:" + JSONObject.toJSONString(entity)).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
		}
		return result;
	}
	
	/**
	 * 获取付款银行信息
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getBankNmKvList.do", method = { RequestMethod.POST})
	@ResponseBody
	public Object getBankNmKvList(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		//获取系统代码和组织结构代码
		String sysCd = CurrentThreadContext.getCurrentSysCd(); 
		String orgCd = CurrentThreadContext.getCurrentOrgCd();
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		SysBkInfoQueryCondition qc = new SysBkInfoQueryCondition();
		qc.setIsValid(BaseConstant.IS_YESNO_YES);//启用
		try {
			//获取数据
			List<KeyValueVO> bankNmKvList = this.assTrailCarMService.searchBankNmKVList(qc, sysCd, orgCd);
			if(CollectionUtils.isNotEmpty(bankNmKvList)){
				JSONArray bankNmKvListJson = JSONArray.fromObject(bankNmKvList.toArray());
				result.setData(bankNmKvListJson);
			}
		}catch(BaseException ex) {
			BaseLogUtils.newLogger("获取付款银行信息失败").setThrowable(ex).error(LogExceptionEnum.COMMON_CODE_0002);
			throw ex;
		}catch(Exception ex) {
            BaseLogUtils.newLogger("获取付款银行信息失败").setThrowable(ex).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
		}
		return result;
	}
	
	/**
	 * 获取付款银行-账号信息
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getAccNoKvList.do", method = { RequestMethod.POST})
	@ResponseBody
	public Object getAccNoKvList(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String bankId = request.getParameter("bankId");
		//获取系统代码和组织机构代码
		String sysCd = CurrentThreadContext.getCurrentSysCd(); 
		String orgCd = CurrentThreadContext.getCurrentOrgCd();
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		List<Long> ids = new ArrayList<Long>();
		SysBkAccInfoQueryCondition qc = new SysBkAccInfoQueryCondition();
		qc.setIsValid(BaseConstant.IS_YESNO_YES);//启用
		qc.setOrgCd(orgCd);//设置组织机构代码
		try {
			if(StringUtils.isEmpty(bankId)){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
				return result;
			}else{
				ids.add(Long.valueOf(bankId));
			}
			qc.setBkIds(ids);
			//获取数据
			List<KeyValueVO> accNoKvList = this.assTrailCarMService.searchAccNoKVList(qc, sysCd, orgCd);
			if(CollectionUtils.isNotEmpty(accNoKvList)){
				JSONArray accNoKvListJson = JSONArray.fromObject(accNoKvList.toArray());
				result.setData(accNoKvListJson);
			}
		}catch(BaseException ex) {
			BaseLogUtils.newLogger("获取付款银行-账号信息失败").setKeys("bankId:" + bankId).setThrowable(ex).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
			throw ex;
		}catch(Exception ex) {
            BaseLogUtils.newLogger("获取付款银行-账号信息失败").setKeys("bankId:" + bankId).setThrowable(ex).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
		}
		return result;
	}
	/**
	 * 获取处置收款表信息
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getAssDealRecAmtList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getAssDealRecAmtList(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String flag = request.getParameter("flag");//返回数据类型标识
		String data_id =  request.getParameter("dataId");
		String dataTypeCd =  request.getParameter("dataTypeCd");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		AssDealRecAmtQueryCondition qc = new AssDealRecAmtQueryCondition();
		qc.setIsDel(BaseConstant.IS_YESNO_NO);//未删除
		if(StringUtils.isNotEmpty(data_id)){
			qc.setDataId(Long.valueOf(data_id));
		}else{
		    result.setSuccess(BaseConstant.IS_YESNO_NO);
		    result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}
		if(StringUtils.isNotEmpty(dataTypeCd)){
			qc.setDataTypeCd(dataTypeCd);
		}else{
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_PARAM_IS_BAD);
			return result;
		}
		try {
			//获取数据
			List<AssDealRecAmtVO> assDealRectAmtList = this.assDealRecAmtService.searchAssDealRectAmtList(qc);
			if(CollectionUtils.isNotEmpty(assDealRectAmtList) && assDealRectAmtList.size() > 0){
				result.setData(assDealRectAmtList.get(0));
			}
			if(StringUtils.isNotEmpty(flag) && flag.equals("1")){
				ListPageVO<AssDealRecAmtVO> listPage = new ListPageVO<AssDealRecAmtVO>(assDealRectAmtList, assDealRectAmtList.size());
				return listPage;
			}
		}catch(BaseException ex) {
			BaseLogUtils.newLogger("获取处置收款表信息失败").setKeys("dataId:" + data_id).setThrowable(ex).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
			throw ex;
		}catch(Exception ex) {
            BaseLogUtils.newLogger("获取处置收款表信息失败").setKeys("dataId:" + data_id).setThrowable(ex).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
		}
		return result;
	}
	
	/**
	 * 到库管管理列表页面
	 */
	@RequestMapping(value = "/toWarehouseListPage.do", method = { RequestMethod.GET})
	public ModelAndView toWarehouseListPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("ass/assTrailCarM/assWarehouseManager");
		String sysCd = CurrentThreadContext.getCurrentSysCd(); 
		String orgCd = CurrentThreadContext.getCurrentOrgCd();
		//获取处置状态
		List<KeyValueVO> dealStsList = this.assTrailCarMService.getKvList(InterfaceConstants.DEAL_STS_CD, sysCd, orgCd);
		view.addObject("dealStsList", dealStsList);
		//获取评价状态
		List<KeyValueVO> evalStsList = this.assTrailCarMService.getKvList(InterfaceConstants.EVAL_STATUS_CD, sysCd, orgCd);
		view.addObject("evalStsList", evalStsList);
		return view;
	}
	/**
	 * 初始化库管管理列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/warehouseInitList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object warehouseInitList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}

		AssTrailCarHvQueryCondition qc = this.initTrailCarHvParam(request, response);
		page.setCondition(qc);
		
		Pager pager = this.assTrailCarHvService.searchListPage(page);
		List<AssTrailCarHvVO> list = (List<AssTrailCarHvVO>) pager.getResultList();
		ListPageVO<AssTrailCarHvVO> listPage = new ListPageVO<AssTrailCarHvVO>(list, pager.getTotalCount());
		return listPage;
	}
	/**
	 * 初始库管管理列表-获取查询参数
	 */
	public AssTrailCarHvQueryCondition initTrailCarHvParam(HttpServletRequest request, HttpServletResponse response) {
		//获取页面参数
		String cstNm = request.getParameter("cstNm");
		String paySchNo = request.getParameter("paySchNo");
		String dealStsCd = request.getParameter("dealStsCd");
		String evalStatusCd = request.getParameter("evalStatusCd");
		String isEnter = request.getParameter("isEnter");
		String isOut = request.getParameter("isOut");
		String minEnterTm = request.getParameter("minEnterTm");
		String maxEnterTm = request.getParameter("maxEnterTm");
		String minOutTm = request.getParameter("minOutTm");
		String maxOutTm = request.getParameter("maxOutTm");

		AssTrailCarHvQueryCondition qc = new AssTrailCarHvQueryCondition();
		if (StringUtils.isNotEmpty(cstNm)) {//客户名称
			qc.setCstNm(cstNm);
		}
		if (StringUtils.isNotEmpty(paySchNo)) {//支付表号
			qc.setPaySchNo(paySchNo);
		}
		if (StringUtils.isNotEmpty(dealStsCd)) {//处置状态
			qc.setDealStsCd(dealStsCd);
		}
		if (StringUtils.isNotEmpty(evalStatusCd)) {//评估状态
			qc.setEvalStatusCd(evalStatusCd);
		}
		if (StringUtils.isNotEmpty(isEnter)) {//是否入库
			qc.setIsEnter(Integer.parseInt(isEnter));
		}
		if (StringUtils.isNotEmpty(isOut)) {//是否出库
			qc.setIsOut(Integer.parseInt(isOut));
		}
		if (StringUtils.isNotEmpty(minEnterTm)) {//入库时间-开始
			qc.setMinEnterTm(DateUtils.formatStringToDate(minEnterTm, DateUtils.YYYY_MM_DD));
		}
		if (StringUtils.isNotEmpty(maxEnterTm)) {//入库时间-结束
			qc.setMaxEnterTm(DateUtils.formatStringToDate(maxEnterTm, DateUtils.YYYY_MM_DD));
		}

		if (StringUtils.isNotEmpty(minOutTm)) {//出库时间-开始
			qc.setMinOutTm(DateUtils.formatStringToDate(minOutTm, DateUtils.YYYY_MM_DD));
		}
		if (StringUtils.isNotEmpty(maxOutTm)) {//出库时间-结束
			qc.setMaxOutTm(DateUtils.formatStringToDate(maxOutTm, DateUtils.YYYY_MM_DD));
		}
		qc.setUsrId(CurrentThreadContext.getCurrentUserId());
		qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
		return qc;
	}
	/**
	 * 到下载页面
	 */
	@RequestMapping(value = "/toDownload.do", method = { RequestMethod.GET})
	public ModelAndView toDownload(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("ass/assTrailCarM/assDownLoad");
		view.addObject("pkId", request.getParameter("pkId"));
		view.addObject("tabNm", request.getParameter("tabNm"));
		view.addObject("flag", request.getParameter("flag"));
		return view;
    }

    /**
     * 获取YQ数据
     */
    @RequestMapping(value = "/searchYQPayInfo.do", method = { RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
    public Object searchYQPayInfo(HttpServletRequest request){
        String prjPrdDtlId = request.getParameter("prjPrdDtlId");
        String assTrailMId = request.getParameter("assTrailMId");
        if(StringUtils.isEmpty(prjPrdDtlId)){
            throw new BaseException("无项目产品明细id");
        }
        if(StringUtils.isEmpty(assTrailMId)){
            throw new BaseException("无拖车主表id");
        }
        try{
            AssTrailCarMVO assTrailCarMVO = this.assTrailCarMService.selectById(Long.valueOf(assTrailMId));
            List<PrjPaySchMYqVO> list = this.assTrailCarMService.searchYQPayInfo(Long.valueOf(prjPrdDtlId), assTrailCarMVO.getCrtTm());
            return new ListPageVO<PrjPaySchMYqVO>(list, list.size());
        }catch(BaseException ex) {
            BaseLogUtils.newLogger("获取YQ数据失败").setThrowable(ex).setKeys("prjPrdDtlId:" + prjPrdDtlId).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
        }catch(Exception ex) {
            BaseLogUtils.newLogger("获取YQ数据失败").setThrowable(ex).setKeys("prjPrdDtlId:" + prjPrdDtlId).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
        }
    }

    /**
     * 获取YQ的未来本金和逾期租金数据
     */
    @RequestMapping(value = "/calcYQOvdAndFutureByPaySchId.do", method = { RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
    public Object calcYQOvdAndFutureByPaySchId(HttpServletRequest request){
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
        String paySchId = request.getParameter("paySchId");
        if(StringUtils.isEmpty(paySchId)){
            throw new BaseException("无支付表id");
        }
        try{
            JSONObject json = this.assTrailCarMService.searchYQOvdAndFutureAmt(Long.valueOf(paySchId));
            result.setData(json);
            return result;
        }catch(BaseException ex) {
            BaseLogUtils.newLogger("获取YQ的未来本金和逾期租金数据").setThrowable(ex).setKeys("paySchId:" + paySchId).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
        }catch(Exception ex) {
            BaseLogUtils.newLogger("获取YQ的未来本金和逾期租金数据").setThrowable(ex).setKeys("paySchId:" + paySchId).setWarning(false).error(LogExceptionEnum.COMMON_CODE_0002);
            throw ex;
        }
    }

}

